Tuesday, July 07, 2009

Connect to wireless network using netsh

If you kinda tired of constantly changing your wireless network when you're at home or office, batch file could be a great help for you. A single click is enough to setup your wireless connection. I was using Net Profiles and I'm a satisfied user, but this single click idea beats Net Profiles.
Of course you've to create a batch file for each connection you want to setup, but that's not too much to do (imho).

FYI, I'm using Vista. For XP, the command could be a bit different but the idea is still the same (c'mon improvise).

Now, here's the simple command line to connect to a wireless lan:
netsh wlan connect name="network name" interface="Connection name under Manage Network Connection" ssid="the ssid"

netsh wlan connect name="hpsetup" interface="Wireless Network Connection" ssid="hpsetup"

in case you use static ip in your office or home, the command goes like this:
netsh interface ipv4 set address "Connection name under Manage Network Connection" static the_static_ip mask the_gateway

netsh interface ipv4 set address "Wireless Network Connection" static

One more thing, running under Vista you need to run the batch file as administrator.

After all, it's only one click away.....


Jay said...

I am trying to use your batch file to connect to my wireless network. I see where you entered the SSID, but don't we need to enter the security key somewhere in that batch file?
Thank you,

Santoso said...

Hi Jay,

You could add key="the security key" to the batch file.

Jay said...

Hi Santoso,

I don't know what I am doing wrong. It doesn't want to get me connected. This is how my batch file exactly looks like:

netsh wlan connect name="MyNetwork"
interface="Wireless Network Connection"

and I save it as .bat file and after I run the file nothing happens.
Would you please tell me what I am doing wrong?

Thank you