Tuesday, May 22, 2012

Automate Wireless Deployment

Configuring WLAN Settings Backup
This has been tested on XP SP3, Vista SP1 and Windows 7. There is a note for XP SP2 on the site that indicates something needs to be installed.
  1. Download the wlan.exe file
    Command Switches Info: 
  2. Unzip the file into a directory that you can easily type from a command prompt.
  3. Configure your wireless card to the SSID you want to connect to with all the settings you want. (You can configure multiple SSIDs here, but I did 1 at a time, a more individualized controlled approach)
    Run Command (wlan.exe ei)
    With Wireless configured, open a command prompt and got to the directory where you unzipped the wlan.exe file, run this command and this will give you the GUID for the wireless card. Copy the GUID (Only the Hex part) from the command prompt as you will use it for the next steps. The GUID will be unique to each computer. Most computers will have 1 wireless interface detected in the system. If you have more than 1, this may not work as well. 
  5. LIST the Currently Configured Profiles:
    Run Command (wlan.exe gpl {guid of interface})
    This will list the currently configured wireless profiles, the profle name is used for the next part and is case sensitive. 
    Run Command (wlan.exe gp {guid of interface} YourSSID > profile.xml)
    This will capture the configuration of the wireless info and copy into an xml file that will be used for the deploy/restore. You can name the file anything you want. I used the SSID as the name for easier identification. 
  7. EDIT the CONFIG:
    Open the profile.xml file with notepad and remove the first and last lines and then save the file. I named the xml files the name of the SSID for easier identification.
    1st line will be “The return profile xml is: “Last Line will be “Command "gp" completed successfully.” 
  9. Copy the script below and save it as a batch (.bat) file with the SSID of the wireless as the name. This is case sensitive, so save according.

    Example: SSID1.bat

    ******START OF SCRIPT******
    @echo off
    echo Grabbing WLAN Interface...
    For /F "skip=2 tokens=1,2" %%A IN ('wlan.exe ei') Do If "%%A"=="GUID:" set Interface=%%B

    echo Adding wlan SSID %~n0
    wlan.exe sp %Interface% %~n0.xml
    set Interface =

    echo SSID: %~n0 has been configured!

    ******END OF SCRIPT******

    *Note: Don't for get the extra line after the "exit" command.

  10. RUN the SCRIPT
    Now you should have 3 files in your folder: WLAN.exe, profile.xml (or what ever you named the file in step 6), and the matching batch file. When the script runs, it will get its file name and add the wireless network to the computer.

If you want to add multiple wireless networks, create a new batch file and add the follow commands into it:
start /w SSID3.bat
start /w SSID2.bat
start /w SSID1.bat
This will run each of the batch file you created in step 8. Order the SSIDs from least preferred to most preferred. The last SSID will be the one that connects first.

Original Source: 

No comments:

Post a Comment