Windows 10

3 Ways to Disable a Network Connection in Windows 10

Windows 10 Hero Good

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.

 

Sponsored Content

Read the Best Personal and Business Tech without Ads

Staying updated on what is happening in the technology sector is important to your career and your personal life but ads can make reading news, distracting. With Thurrott Premium, you can enjoy the best coverage in tech without the annoying ads.

Method 1: Using WMIC

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)
Grabbing the index number of the network interface. (Image Credit: Daniel Petri)

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

Disabling the network interface. (Image Credit: Daniel Petri)
Disabling the network interface. (Image Credit: Daniel Petri)

Now in the control panel, you should see that the desired network connection is now disabled.

Disabled wi-fi connection in the control panel. (Image Credit: Daniel Petri)
Disabled wi-fi connection in the control panel. (Image Credit: Daniel Petri)

To enable the network interface with the required index number, type the following.

wmic path win32_networkadapter where index=4 call enable

Enabling the network interface in the command line. (Image Credit: Daniel Petri)
Enabling the network interface in the command line. (Image Credit: Daniel Petri)
The Wi-Fi network is now enabled. (Image Credit: Daniel Petri)
The Wi-Fi network is now enabled. (Image Credit: Daniel Petri)

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

Method 2: Using NETSH

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)
Using netsh in the command line. (Image Credit: Daniel Petri)

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

control-wifi-cmd-7

Method 3: Using PowerShell

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 in Windows PowerShell. (Image Credit: Daniel Petri)

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.

Adding a switch statement. (Image Credit: Daniel Petri)
Adding a switch statement. (Image Credit: Daniel Petri)

Related Topics:

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register
Comments (0)

Leave a Reply

Download this eBook!

External Sharing and Guest User Access in Microsoft 365 and Teams

his eBook will dive into policy considerations you need to make when creating and managing guest user access to your Teams network, as well as the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure. The eBook will also outline some of the major decision points across four general-purpose guest access policy scenarios for how an organization can set this up with standard licensing.

Download Now

Sponsored By