Thursday, July 28, 2011

How to connect to a Wireless WIFI Network from the Command line in Windows 7

C:\>netsh wlan connect name=HANSELMAN-N

Connection request was completed successfully.

More Details

What happened there? Well, the command line is netsh wlan and the full one is

netsh wlan connect ssid=YOURSSID name=PROFILENAME

What's a profile? It's the only thing required. You can see them with:

C:\>netsh wlan show profile

Profiles on interface Wireless Network Connection:
.
..snip..
User profiles
-------------
All User Profile : Clear Spot b0e
All User Profile : HANSELMAN-N
All User Profile : Quiznos

These are the same ones that you see in the wireless networks dialog

More Details

What happened there? Well, the command line is netsh wlan and the full one is

netsh wlan connect ssid=YOURSSID name=PROFILENAME

What's a profile? It's the only thing required. You can see them with:

C:\>netsh wlan show profile

Profiles on interface Wireless Network Connection:
.
..snip..
User profiles
-------------
All User Profile : Clear Spot b0e
All User Profile : HANSELMAN-N
All User Profile : Quiznos

These are the same ones that you see in the wireless networks dialog

You can set these up and refer to them by name from the command line, or a batch file, etc. Nice to do for the places you are regularly.

If you have multiple wireless cards (What's wrong with you!?) then you have to be more specific:

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

And of course, you can

netsh wlan disconnect

And include the interface optionally, for multiple interfaces. Additionally, interesting things can be seen with

netsh wlan dump

This is nice because you can

netsh wlan dump > myconfig.txt

on one machine and then later on another machine

netsh exec myconfig.txt

All this command line love will work in most versions of Windows, actually, not just 7 AFAIK. There's lots of more detail and docs on managing Wireless Profiles on the Web.

Enjoy! (From Scott Hanselman Blog)

No comments: