Netsh wlan show networks Interface Name : Wireless Network Connection There are 2 networks currently visible SSID 1 : Litware Network Type : Infrastructure Authentication : Open Encryption : None SSID 1 : Contoso Network Type : Infrastructure Authentication : Open Encryption : WEP
Before you can connect to a wireless network using Netsh, you must have a profile saved for that network. Profiles contain the SSID and security information required to connect to a network. If you have previously connected to a network, the computer will have a profile for that network saved. If a computer has never connected to a wireless network, you need to save a profile before you can use Netsh to connect to it. You can save a profile from one computer to an Extensible Markup Language (XML) file and then distribute the XML file to other computers in your network. To save a profile, run the following command after manually connecting to a network.
Netsh wlan export profile name="SSID
" Interface profile "SSID
" is saved in file ".\Wireless Network Connection-SSID
.xml" successfully.
Before you can connect to a new wireless network, you can load a profile from a file. The following example demonstrates how to create a wireless profile (which is saved as an XML file) from a script or the command line.
Netsh wlan add profile filename="C:\profiles\contoso1.xml" Profile contoso1 is added on interface Wireless Network Connection
To connect to a wireless network quickly, use the netsh wlan connect command and specify a wireless profile name (which must be configured or added previously). The following examples demonstrate different but equivalent syntaxes for connecting to a wireless network with the Contoso1 SSID.
Netsh wlan connect Contoso1 Connection request is received successfully Netsh wlan connect Contoso1 interface="Wireless Network Connection" Connection request is received successfully
Note that you need to specify the interface name only if you have multiple wireless network adapters—an uncommon situation. You can use the following command to disconnect from all wireless networks.
Netsh wlan disconnect Disconnection request is received successfully
You can use scripts and profiles to simplify the process of connecting to private wireless networks for your users. Ideally, you should use scripts and profiles to save users from ever needing to type wireless security keys.
You can also use Netsh to allow or block access to wireless networks based on their SSIDs. For example, the following command allows access to a wireless network with the Contoso1 SSID.
Netsh wlan add filter permission=allow ssid=Contoso networktype=infrastructure
Similarly, the following command blocks access to the Fabrikam wireless network.
Netsh wlan add filter permission=block ssid=Fabrikam networktype=adhoc
To block all ad hoc networks, use the Denyall permission, as the following example demonstrates.
Netsh wlan add filter permission=denyall networktype=adhoc
To prevent Windows from automatically connecting to wireless networks, run the following command.
Netsh wlan set autoconfig enabled=no interface="Wireless Network Connection"
You can also use Netsh to define the priority of user profiles (but not Group Policy profiles). Group Policy profiles always have precedence over user profiles. The following example demonstrates how to configure Windows to connect automatically to the wireless network defined by the Contoso profile before connecting to the wireless network defined by the Fabrikam profile.
Netsh wlan set profileorder name=Contoso interface="Wireless Network Connection" priority=1 Netsh wlan set profileorder name=Fabrikam interface="Wireless Network Connection" priority=2
Netsh has many other commands for configuring wireless networking. For more information, run the following at a command prompt.
Netsh wlan help