Friday, June 21, 2013

Easily share wireless settings

I was faced with an issue where I had multiple users that required a wireless profile to be setup.  Unfortunately, the powers that be, determined that the wireless settings should be as complicated as possible.  To make things easier, I came up with the following way of automating the setup of a wireless profile on Windows 7.
To begin, I started with one laptop that was setup with the wireless profile I wanted to replicate. I opened the command prompt and used netsh to export the wireless profile as XML.  Make sure netsh can see the wireless profile by typing "netsh wl show profiles" at the command prompt.

The wireless adapter must be on/enabled for netsh to be able to import or export a wireless profile.

C:\Users\rob\wifi>netsh wl show profiles

Profiles on interface Wireless Network Connection:

Group policy profiles (read only)
---------------------------------
   

User profiles
-------------
    All User Profile     : VanEtta

C:\Users\rob\wifi>

In this example, I will be exporting the "VanEtta" profile by typing the following:

C:\Users\rob\wifi>netsh wl export profile name="VanEtta"

Interface profile "VanEtta" is saved in file ".\Wireless Network Connection-VanEtta.xml" successfully.


C:\Users\rob\wifi>

Next, open the file in notepad.  It will look similar to the following:


We are going to "convert" this XML file in to a batch file that automatically configures the wireless profile.  I developed the following script that you can use at the start of your XML:

@echo off&&type "%~fx0" | find "<" | find /v "rfv3.xml" > .\rfv3.xml
netsh wl ad pro fi=".\rfv3.xml"|find "no wire" >nul &&echo Wireless must be enabled!&&pause
del .\rfv3.xml&exit 

Simply copy the above code and paste it before the start of the XML as follows:


Finally, save the file as a batch file by changing the file extension to ".bat" (or ".cmd").   Make sure that you place quotation marks before and after the file name so that notepad doesn't attempt to change the extension back to ".txt".


Now, you can distribute the file freely and it can be imported by simply double clicking icon.  If a standard user double clicks the file, it will import the wireless profile to the user's profile.  If you right click on the script and "Run as administrator...", it will import the profile for all users.

A couple caveats: The script will only work when wireless is enabled.  Also, it isn't written in a way that will work from a network path; if this is something you require, you can use pushd/popd to temporarily map a drive letter to the network path.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.