
close
close
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
Grabbing the index number of the network interface. (Image Credit: Daniel Petri)
wmic path win32_networkadapter where index=4 call disable
Disabling the network interface. (Image Credit: Daniel Petri)
Disabled wi-fi connection in the control panel. (Image Credit: Daniel Petri)
wmic path win32_networkadapter where index=4 call enable
Enabling the network interface in the command line. (Image Credit: Daniel Petri)
The Wi-Fi network is now enabled. (Image Credit: Daniel Petri)
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
Using netsh in the command line. (Image Credit: Daniel Petri)
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.
Get-NetAdapter in Windows PowerShell. (Image Credit: Daniel Petri)
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.
Adding a switch statement. (Image Credit: Daniel Petri)
More in Windows 10
Microsoft to Start Notifying Windows 8.1 Users About Upcoming End of Support
Jun 24, 2022 | Rabia Noureen
Microsoft's Out-Of-Band Patch Fixes Microsoft 365 and Azure AD Sign-In Issues on ARM Devices
Jun 21, 2022 | Rabia Noureen
Microsoft is Investigating Sign-In Issues Affecting Microsoft 365 and Azure AD on ARM Devices
Jun 20, 2022 | Rabia Noureen
Microsoft to Fix Windows Bug Breaking Wi-Fi hotspots After Installing Latest Patch Tuesday Update
Jun 17, 2022 | Rabia Noureen
Most popular on petri