Last Update: Sep 04, 2024 | Published: Apr 21, 2016
When we use a computer over a Wi-Fi network, there are some cases in which we want to disable that connection. Usually, this can be done by going to the Network Connections applet in Control Panel, but since Microsoft made it a little more complicated to get to it, it might be easier to have a shortcut on your desktop that lets you do just that.
For this purpose, I made a list of three easy methods of using the command prompt, which includes some PowerShell commands that can help you do this with ease. Note that these commands should work on Windows 7, 8, and 8.0, and you’ll need to open the command prompt or PowerShell with administrative permissions to properly run these commands.
To use the WMIC command in the command prompt, we need to identify the correct index number of the required network interface, which we’ll then use to enable or disable the network.
To get the network interface list and index number type:
wmic nic get name, index
Type the following to disable the network interface with the required index number, which let’s say is 4 for this example:
wmic path win32_networkadapter where index=4 call disable
Now in the control panel, you should see that the desired network connection is now disabled.
To enable the network interface with the required index number, type the following.
wmic path win32_networkadapter where index=4 call enable
If you only want to enable and/or disable the Wi-Fi adapters, you can use these 2 lines:
wmic path win32_networkadapter where NetConnectionID="Wi-Fi" call disable wmic path win32_networkadapter where NetConnectionID="Wi-Fi" call enable
Note: For some previous operating systems, replace “Wi-Fi” with “Wireless”, that should do the trick. Anyway, if you want to know how your computer treats any specific NIC adapter, add “NetConnectionID” to the first WMIC command:
wmic nic get name, index, NetConnectionID
If you want to be a bit more sophisticated, you can use a “like” option to identify the “NetConnectionID”:
wmic path win32_networkadapter where 'NetConnectionID like "%Wi-Fi%" ' call enable
To perform the same task but with the NETSH command in command prompt, we need to identify the name of the required network interface, which we’ll then use it to enable or disable it, as needed.
To get the network interface name type:
netsh interface show interface
To disable the network interface with the required name: (for example: Wi-Fi)
netsh interface set interface "Wi-Fi" disabled
To enable the network interface with the required name: (for example: Wi-Fi)
netsh interface set interface "Wi-Fi" enabled
Obviously, PowerShell can also be used to perform these tasks, and although it’s possible to run many types of scripts that will do this and much more, there are a few simple commands that we can use for the purpose of disabling and enabling the Wi-Fi network interface.
To get the network interface list, use the Get-NetAdapter cmdlet.
To enable the network interface with the required name: (for example: Wi-Fi)
Get-NetAdapter -Name wi-fi | Enable-NetAdapter
To disable the network interface with the required name: (for example: Wi-Fi)
Get-NetAdapter -Name wi-fi | Disable-NetAdapter -Confirm:$false
Note that we’re adding the “-Confirm:$false” switch to avoid having to acknowledge the prompt.