Windows – how to turn wireless on/off from command line on windows 7+


If, on a Windows 7 machine, I run either of the commands below, while running Windows Mobility Center ("C:\Windows\System32\mblctr.exe" /open)

netsh interface set interface "Wireless Network Connection" admin=disabled
netsh interface set interface "Wireless Network Connection" admin=enabled

the network adapter disappears/reappears on the system, shown as There are no network adapters in your system.

If, with that interface enabled, and connected to wireless network xxx, I do

netsh wlan disconnect interface"Wireless Network Connection"
netsh wlan connect name=xxx ssid=xxx interface"Wireless Network Connection"

I get disconnected/reconnected from the wireless network.

Now, Windows Mobility Center also has up a toggle button that reads Turn wireless on (or off), which, while I disconnect/connect as above always stays on. Turning that button on and off is probably equivalent to toggling the switch on the laptop that disables the wireless radio, as netsh complains that the interface is powered down if I try to do anything to it after turning it off from Windows Mobility Center.

So the question is, how to turn Wireless on or off from the command line, or maybe more precisely, how to turn power off and on to the wireless interface, again, from the command line.

Can't find an answer with google or here on superuser. Maybe wmic can do it?