Sure, you can configure your wireless network connection in Windows Vista using the GUI. Although it is not always that simple, just about everyone has learned to do it. However, how about configuring wireless from the command line? Let us find out why you would want to do this, how you would do it, and then see it in action!Why would you want to use the command line to configure wireless networking?
Some of you might be asking why you would want to do this in the first place and that is a logical question. Let me provide some justification for the reason behind this and help demonstrate the need to you.
- Using the CLI when no GUI is available: You never know when you will need to configure something (like wireless) from the command line because no GUI is available. This could happen for a number of reasons. With the commands you learn in this article, you will be prepared.
- Using the CLI when scripting: The day may come (or it may be here now) when you need to write a script to connect to a wireless network. If you create that script, you will need to know all the necessary Netsh WLAN commands needed to accomplish your task, inside the script. For example, you might want to configure wireless connectivity in a logon script.
- Because it is faster: Some of us are just command line junkies and we enjoy using the command line to do things over the GUI. In fact, for some of you out there, you are fast enough at the command line that you can do things faster in the CLI than you can in the GUI.
The Netsh WLAN command set is only offered in Windows Vista (not in XP, 2003, or 2008 Server). So what can you do with these commands? Here is a list:
- Configure wireless security settings for this Windows PC or laptop.
- Configure wireless connectivity and network settings for this Windows PC or laptop -- for example, when logging in, you could configure a laptop to connect securely to the company wireless network.
- View the wireless group policy settings that are applied to this Windows machine.
- Connect to mixed mode networks -- for example, you can connect to either a WPA or WPA2 wireless network.
- Hide wireless networks from end users -- with Netsh WLAN, you can hide from your end users or prevent end users from connecting to potentially malicious or just undesirable wireless networks.
With that, let us see how Netsh WLAN works.Creating profiles and connecting to a Wireless LAN using Netsh WLAN
Now that we have seen some possible uses for Netsh WLAN, let me show you, on a real Windows Vista machine, how to use these commands to do certain tasks.
To view all the options for Netsh WLAN, simply type netsh wlan without any options and you will see this:
Figure 1: Netsh WLAN help options
To really connect, the first thing you need to do is create a profile. As the creation of a profile works off of an existing profile file that you have already saved, we first need to create our saved XML file.
On a Vista machine that already has a working wireless network, you would run the following command:
Netsh WLAN export profile name="BOW" folder=C:\Users\David\wlan interface="Wireless Network Connection"
This would create a file called:
- Wireless Network Connection-BOW.xml
- In folder C:\Users\David\wlan
Figure 2: Netsh WLAN export example
You would then import this file onto the system that you want to add the profile on and connect to the wireless network.
To create a profile to connect to the wireless LAN (WLAN) on the new machine, I would do this (assuming I changed directory into the "wlan" folder):
C:\Users\David\wlan> Netsh WLAN add profile filename="Wireless Network Connection-BOW.xml"
Figure 3: Adding a new profile with Netsh WLAN
Optionally, you could choose to add this profile only for a certain wireless interface or for certain users.
Once the profile is added, you should be able to verify that it is there with this:
Netsh WLAN show profiles
Figure 4: Showing wireless profiles with Netsh WLAN
You can see the settings for those profiles with the following command line:
Netsh WLAN show settings
Once you know that you have a profile, you can use that profile to connect, like this (assuming the profile did not specify auto-connection):
Netsh WLAN connect ssid="mySSID" name="WLAN-Profil1"
As you can see below, we are connected to the wireless network:
Figure 5: Results of connecting to the WLAN
If there is only one interface on the computer and the security settings in the profile are correct, at this point, you should be connected to the WLAN.What else can Netsh WLAN do?
Besides just adding or deleting profiles and connecting or disconnecting to wireless networks, what else can Netsh WLAN do for you?
Actually, there are a number of other capabilities that Netsh WLAN can perform. Here is a list:
- Dump wireless settings: By running Netsh WLAN dump and directing it to a text file, you can create a script that you could use to very quickly get your wireless network adaptor reconfigured. Once you have your wireless network configured and connected, I recommend creating this WLAN configuration script with this command:
Netsh WLAN dump > mywlandump.txt
- Add a filter: With the Netsh WLAN add command, you can also add a wireless network filter, as well as a profile.
- Show and set autoconfig: When auto-configuration is enabled on a wireless interface that means the interface will automatically connect with its wireless profile. This is enabled by default. You can check your settings with Netsh WLAN show autoconfig. You can change your autoconfig settings with set autoconfig enabled=no interface="Wireless Network Adaptor"
- Show and set blockednetworks: Wireless networks can be hidden or blocked. Perhaps you want the blocked networks to be shown in the list of available networks but listed as "blocked." To hide blocked networks from the list of available networks, use Netsh WLAN set blockednetworks display=hide
- Show and set if you are allowed to create wireless profiles for all users on that machine: This one is self-explanatory, with the show command you can see if you are allowed.
- Show and set the profile order: When it comes to which profile will be used on an interface if multiple profiles are present, the profile order is used. With the show and set profile commands you can simply view or change this profile order from the command line.
- Show and set whether tracing is on or off: Tracing is essentially event logging for your wireless device. When you enable tracing with the command Netsh WLAN set tra yes you will find the log of those traces in %WINDIR%\tracing\wireless
The Netsh WLAN command is a new and very useful command set for Windows Vista. With these commands, you can very easily add wireless profiles and connect to wireless networks from a command line and through scripts.
About David Davis
WindowsNetworking.com contains a wealth of networking information for administrators: Featuring information on how to setup and troubleshoot various networks of any size. Also includes a comprehensive archive of hundreds of reviewed networking software and hardware solutions. Frequently updated with articles and tips by a team of leading authors, it remains a favorite within the networking community.