Search code examples
windowscommand-linewmicnetsh

Disable/Enable All Network Adapters (NIC) using netsh/wmic


Is there any way to disable/enable all of network adapters at ONCE using netsh or wmic?

Currently using netsh you can use the code below:

netsh interface set interface <interfacename> disabled

As you can see, you must enter the interface name, Just think there is several network adapters and you need to disable all of them at once, is there any way to do that using command prompt?


Solution

  • Here's an illustrative and apposite example (run cmd as administrator, otherwise you will get ReturnValue = 5;, i.e. Access denied):

    C:\Windows\system32>wmic path win32_networkadapter get name, NetEnabled, InterfaceIndex
    InterfaceIndex  Name                                                  NetEnabled
    3               Realtek PCIe GBE Family Controller                    FALSE
    2               Sítový adaptér ladení jádra spolecnosti Microsoft
    4               Microsoft ISATAP Adapter
    5               Adaptér tunelového rezimu Microsoft Teredo
    
    
    C:\Windows\system32>wmic path win32_networkadapter where "NetEnabled='FALSE'" call enable
    Executing (\\USER-PC\root\cimv2:Win32_NetworkAdapter.DeviceID="0")->enable()
    Method execution successful.
    Out Parameters:
    instance of __PARAMETERS
    {
            ReturnValue = 0;
    };
    
    
    C:\Windows\system32>wmic path win32_networkadapter get name, NetEnabled, InterfaceIndex
    InterfaceIndex  Name                                                  NetEnabled
    3               Realtek PCIe GBE Family Controller                    TRUE
    2               Sítový adaptér ladení jádra spolecnosti Microsoft
    4               Microsoft ISATAP Adapter
    5               Teredo Tunneling Pseudo-Interface
    
    
    C:\Windows\system32>