How to: Manage Wireless Connections with Netsh in Vista, Part 2

By Eric Geier

March 10, 2009

In Windows Server 2008 and Vista, Microsoft added WLAN commands to Netsh, a command-line utility in Windows. This now provides the ability to manage wireless adapters, wireless network profiles, and Wi-Fi connectivity from the Command Prompt.

A few months ago, we covered how to manage wireless connections with Netsh, a command-line utility of Windows. In Windows Server 2008 and Vista, Microsoft added WLAN commands to Netsh. This now provides the ability to manage wireless adapters, wireless network profiles, and Wi-Fi connectivity from the Command Prompt.

In the previous tutorial, we explained how to use the tool to import and export wireless profiles, and how to block connections to specific Wi-Fi networks. We also saw how the commands could be used in batch files to help automate the wireless configuration of computers.

Now in this tutorial, we’ll discover a few more features of the Netsh WLAN commands. We’ll see how to export or dump the wireless settings, and to import them into another PC. We’ll also enable and disable the Windows wireless utility, connect and disconnect from Wi-Fi networks, set the network priorities, and activate wireless tracing to aid in troubleshooting.

Dumping and importing the WLAN configuration

In the previous tutorial, we discussed using the Netsh WLAN commands in batch files to help automate the wireless configuration of computers. Another technique is to use Netsh itself. Once a computer’s current configuration is dumped into a text file, it can be imported into other computers. This does not include the wireless network profiles though, just the basic configuration, such as the filter and block lists. Profiles will have to be imported separately, if desired.

Here is the syntax to dump the configuration (see Figure 1, below):

netsh wlan dump >c:wlanconfig.txt

Tutorial - Geier E - 1109 - Fig1_sm2.jpg

Click to enlarge.

Tip: The Command Prompt will probably have to be opened with administrative privileges in order to dump the file onto the C drive’s root directory. To run the Command Prompt elevated, enter cmd into the start menu’s search box, right-click the cmd icon, and select Run as administrator.

Once a WLAN configuration is dumped into a text file, it can be imported onto other computers, or on the same PC to restore the configuration (see Figure 1):

netsh exec c:wlanconfig.txt

Enabling and disabling the Wireless-Auto-Config service

The Wireless-Auto-Config service controls Vista’s wireless connectivity interface and functionally. It is enabled by default, but the service can be toggled on and off. Disabling the service, for example, is useful when using a third-party wireless utility. The service can be alternatively managed through the Windows Services tool, however it can only be turned on or off for individual wireless connections or adapters with the Netsh utility; useful if a computer has multiple wireless cards.

Here’s the syntax to enable or disable the Wireless-Auto-Config service (see Figure 2):

netsh wlan set autoconfig enabled={yes|no} interface="WIRELESS NETWORK CONNECTION”

Tutorial - Geier E - 1109 - Fig2_sm.jpg

Click to enlarge.

Connecting and disconnecting from wireless networks

The Netsh WLAN commands also provide the ability to connect to and disconnect from Wi-Fi networks. These commands could be used in scripts or batch files, such as when performing a computer’s initial configuration.

Here is the syntax to connect to a wireless network (see Figure 3, below):

netsh wlan connect ssid=SSID name=PROFILENAME interface="WIRELESS NETWORK CONNECTION”

Tutorial - Geier E - 1109 - Fig3_sm.jpg

Click to enlarge.

The SSID (or network name) and Profile name is always required, while the Interface name is only required if multiple wireless connections or adapters exist on the computer. If needed, reference this information by entering netsh wlan show profiles.

To disconnect from the currently connected wireless network, use the following syntax at the Command Prompt (see Figure 3):

netsh wlan disconnect interface="WIRELESS NETWORK CONNECTION”

Again, the Interface name is only required if there are multiple wireless connections.

Setting the profile order for wireless networks

In the previous tutorial, we also exported and imported profiles for wireless networks. To get the most out of the Windows wireless utility, though, the profiles should be ordered based upon priority. That way if multiple networks exist in an area, Windows will connect to them based on the defined order.

Use the following syntax to set a profile’s priority number (see Figure 4, below):

netsh wlan set profileorder name="PROFILENAME" interface="WIRELESS NETWORK CONNECTION” priority=#

Tutorial - Geier E - 1109 - Fig4_sm.jpg

Click to enlarge.

The priority numbers start with 1 and go up from there, with the lower numbers being higher priority. Setting a profile to 0 or 1 will make it the highest priority, moving any existing profile in the first position to a lower priority.

To see the existing profile ordering, enter netsh wlan show profiles. Though priority numbers aren’t shown, they are listed in the proper order.

Enabling and using tracing

The wireless tracing or logging feature of Vista can be enabled or disabled using the Netsh utility. If there are connection problems with a wireless network, tracing can be temporarily or permanently activated. After the capture is complete, loads of information and raw data are available to help when doing advanced troubleshooting.

Here’s the syntax to change the wireless tracing mode (see figure, click to enlargeTutorial - Geier E - 1109 - Fig5_sm.jpg):

netsh wlan set tracing mode={yes|no|persistent}

Choosing the Persistent Mode means tracing will remain active indefinitely, rather than being turned off after the system restarts.

The trace files are stored at C:windowstracingwireless. In addition to the report (generated after tracing has been turned off) being available in that directory, it can be viewed using the Windows performance monitor, such as Figure 6 (below) shows. In the Control Panel, open the Administrative Tools window, and open the Reliability and Performance Monitor. In the left pane of the monitor’s window, browse to Reports>System>Wireless Diagnostics>Wireless. The trace directory also contains a repacked CAB file, so the report can be quickly sent to someone or archived.

Tutorial - Geier E - 1109 - Fig6_sm.jpg

Click to enlarge.

Command with caution

Between this and the previous tutorial, we’ve covered just about all the WLAN commands the Netsh command-line utility provides. Remember, Netsh is a powerful tool and should be used with caution. The default interactive online mode applies changes immediately. Therefore, it might be useful to use interactive offline, or non-interactive mode, because the changes can be reviewed before applying.

Eric Geier is the author of many networking and computing books, including Home Networking All-in-One Desk Reference For Dummies (Wiley 2008) and 100 Things You Need to Know about Microsoft® Windows Vista (Que 2007).

Originally published on .

Comment and Contribute
(Maximum characters: 1200). You have
characters left.