Search code examples
batch-filecmdcommand-promptwmicnetsh

How to disable multiple network adapters from windows command prompt with wildcard


I'm trying to disable multiple network adapters having a similar name in batch. Some resources I've found seem to suggest that "call disable" should work

wmic nic where "Name like 't%'" call disable

however I get disable - Invalid alias verb.

I can get the adapter names via:

wmic nic where "Name like 't%'" GET name

but any attempt at looping to disable them has been a fail (no real experience with cmd commands). Also took a look at netsh - not sure which is better suited for this simple task.


Solution

  • Got it. I used:

    wmic path win32_networkadapter where "Name like 't%'" call disable
    

    or with double percent %% to escape it if in batch file (also have to run as admin)

    wmic path win32_networkadapter where "Name like 't%%'" call disable