Thursday, March 22, 2012

Automate Windows Vista/7/8 Wifi Profile Importing using NETSH

If you work in an enterprise environment that provides wireless you may find it necessary to constantly be configuring WiFi profiles for your users as they aren't able to do it themselves. With more advanced security features you can  implement with 802.1x for instance you may find that simply trying to connect to the WiFi network and entering in your credentials won't work - you need more manual configuration.

Well screw that! Let's make a batch file and do this in 2 clicks!



To start you will need to configure a test machine with all the wireless profiles configured manually (for the last time!).

Once you have those setup, it's time to export those profiles with NETSH.

Open up a command prompt and type:

netsh wlan show profiles 

This will show all profiles you have configured on your test machine.

netsh wlan export profile name="wifiprofile1" folder="c:\wifiprofiles\" 

Feel free to use whatever local or network drive you'd like to save these profiles on instead of c:\wifiprofiles.

Now, lets create a batch file we can use to import these new profiles to other laptops. Make sure to create this batch file in the same folder you saved your profiles in unless you want to specify the full path. Create a new text file with notepad but be sure to save it as a .bat or .cmd.

The general setup is below; add more profiles as necessary.


@echo off
echo.
echo Importing 802.1x Profiles
echo.
netsh wlan add profile filename="wifiprofile1.xml" user=all
netsh wlan add profile filename="wifiprofile2.xml" user=all
pause
And that's it. Either host this folder on a network share for users or yourself to grab and import over the wired network during initial laptop deployment or put it on your image in advance. You can even include this during sysprep to do this automatically.

NETSH is a super powerful command line tool that I will elaborate on more in later posts. For now, enjoy our automation!

2 comments:

  1. Hello, thanks for the info. But when I import this over to another laptop from my test laptop then running the batch script, it ask for the Security key. Anyway I can automate so the security key is imported as well?

    ReplyDelete
  2. This wonderful person seems to have fixed it with this method: http://theether.net/kb/100166

    ReplyDelete