Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

How to Capture and Deploy WLAN Profiles

Created: 20 Feb 2009 | 35 comments
Language Translations
SK's picture
+5 5 Votes
Login to vote

As PC Transplant is not able to capture WLAN profiles, how can this goal still be achieved?

The following method can be used on Windows XP Service Pack 2 and Service Pack 3.

Requirements for Service Pack 2:

  1. Download and install Wireless LAN API (KB918997)

    Installing this set of application programming interfaces (APIs) will enable you to create applications that can manage wireless LAN profiles and connectivity on Microsoft Windows XP Service Pack 2 (SP2) using the native wireless functionality in Windows, called Wireless Zero Configuration (WZC) service.

  2. Start the Wireless Zero Configuration service.

Requirements for Service pack 3:

Even though the Wireless Zero Configuration service is set to Automatic, you may find that it is not running, so you will need to start it.

The tool that will allow you to obtain the WLAN profiles as well as deploy them to other machines is called WLAN.exe and is attached to this article.

WLAN.exe has the following command line parameters:

  • EnumInterface(ei)
  • GetInterfaceCapability(gic)
  • QueryInterface(qi)
  • SetRadioState(srs)
  • GetDriverStatistics(gds)
  • Scan(scan)
  • GetBssList(gbs)
  • GetVisibleNetworkList(gvl)
  • SetProfile(sp)
  • SaveTempProfile(stp)
  • GetProfile(gp)
  • DeleteProfile(dp)
  • SetProfileList(spl)
  • GetProfileList(gpl)
  • Connect(conn)
  • Disconnect(dc)
  • Discover(disc)
  • RegisterNotif(r)
  • help(?)

Below is the description for each of those commands:

Command: EnumInterface(ei)
Description: Enumerate wireless interfaces and print the basic interface information.
Usage: EnumInterface(ei)
Command: GetInterfaceCapability(gic)
Description: Get the capability of an interface.
Usage: GetInterfaceCapability(gic) <interface GUID>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: QueryInterface(qi)
Description: Query the basic information of an interface.
Usage: QueryInterface(qi) <interface GUID>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: SetRadioState(srs)
Description: Set the software radio state.
Usage: SetRadioState(srs) <interface GUID> <on|off>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: GetDriverStatistics(gds)
Description: Get driver statistics.
Usage: GetDriverStatistics(gds) <interface GUID>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: Scan(scan)
Description: Scan for available wireless networks.
Usage: Scan(scan) <interface GUID>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: GetBssList(gbs)
Description: Get the list of BSS.
Usage: GetBssList(gbs) <interface GUID> [<SSID> <infrastructure(i)|adhoc(a)> <secure(s)|unsecure(u)>]
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: GetVisibleNetworkList(gvl)
Description: Get the list of visible wireless networks.
Usage: GetVisibleNetworkList(gvl) <interface GUID>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: SetProfile(sp)
Description: Save a profile.
Usage: SetProfile(sp) <interface GUID> <profile XML file name>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: SaveTempProfile(stp)
Description: Save the temporary profile used for the current connection.
Usage: SaveTempProfile(stp) <interface GUID> <profile name>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: GetProfile(gp)
Description: Get the content of a saved profile.
Usage: GetProfile(gp) <interface GUID> <profile name>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: DeleteProfile(dp)
Description: Delete a saved profile.
Usage: DeleteProfile(dp) <interface GUID> <profile name>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: SetProfileList(spl)
Description: Set the preference order of saved profiles. The list must contain all profiles.
Usage: SetProfileList(spl) <interface GUID> <profile name>+
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: GetProfileList(gpl)
Description: Get the list of saved profiles, in the preference order.
Usage: GetProfileList(gpl) <interface GUID>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: Connect(conn)
Description: Connect to a wireless network using a saved profile.
Usage: Connect(conn) <interface GUID> <SSID> <infrastructure(i)|adhoc(a)> <profile name>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: Disconnect(dc)
Description: Disconnect from the current network.
Usage: Disconnect(dc) <interface GUID>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: Discover(disc)
Description: Connect to a network without a saved profile. The WLAN service will discover the settings for connection.
Usage: Discover(disc) <interface GUID> <SSID> <infrastructure(i)|adhoc(a)> <secure(s)|unsecure(u)>
Remarks: Use EnumInterface (ei) command to get the GUID of an interface.
Command: RegisterNotif(r)
Description: Register ACM and MSM notifications.
Usage: RegisterNotif(r)
Command: help(?)
Description: Print this help message.
Usage: help(?) [<command>]

Here is a basic example of how you can use this tool, once the Wireless Zero Configuration service has been started.

Capture phase:

  1. Enumerate Interfaces - wlan.exe ei

    There are 1 interfaces in the system.

    Interface 0:
    GUID: 89762a5d-bc6b-4ac6-8cf3-b0462b2bafef
    Intel(R) PRO/Wireless 3945ABG Network Connection - Teefer2 Miniport
    State: "disconnected"
    Command "ei" completed successfully.
    
    
  2. Get Profile List - wlan.exe gpl 89762a5d-bc6b-4ac6-8cf3-b0462b2bafef

    There are 1 profiles on the interface.

    "Profile1"
    Command "gpl" completed successfully.
    
    
  3. Get Profile (profile name is case sensitive) - wlan.exe gp Profile1

    The return profile xml is:

    <?xml version="1.0"?>
    <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    	<name>Profile1</name>
    	<SSIDConfig>
    		<SSID>
    			<hex>574C414E2D445341444B</hex>
    			<name>Profile1</name>
    		</SSID>
    	</SSIDConfig>
    	<connectionType>ESS</connectionType>
    	<MSM>
    		<security>
    			<authEncryption>
    				<authentication>open</authentication>
    				<encryption>WEP</encryption>
    				<useOneX>false</useOneX>
    			</authEncryption>
    			<sharedKey>
    				<keyType>networkKey</keyType>
    				<protected>false</protected>				<keyMaterial>76A3DEC BA383180E8A18E4E522</keyMaterial>
    			</sharedKey>
    			<keyIndex>0</keyIndex>
    		</security>
    	</MSM>
    </WLANProfile> 
    Command "gp" completed successfully.
    
    

Deploy Phase (setting the profile):

wlan.exe sp 89762a5d-bc6b-4ac6-8cf3-b0462b2bafef C:\Profile1.xml

Conclusion:

As you can see, this tool has many functions, and all of them can be scripted in order to allow you to develop an automated method of capturing and deploying WLAN profiles.

License: Altiris EULA
By downloading this software, you agree to the terms and conditions in the Altiris End User License Agreement
Support: User-contributed tools on the Juice are not supported by Altiris Technical Support. If you have questions about a tool, please communicate directly with the author by visiting their profile page and clicking the 'contact' tab.

Comments 35 CommentsJump to latest comment

spazzzen's picture

Does this have to be installed on the PC you are going to deploy to? Also is it a new wireless utility or does it just link into the windows one to allow for import/export of wireless profiles?

0
Login to vote
dcudney's picture

Good job on this tool. This is going to help me out a lot!  One note though, your syntax for obtaining the XML is just a little off. You have to include the GUID in order to get the profile information.

Get Profile (profile name is case sensitive) - wlan.exe gp Profile1

Should be:

Get Profile (profile name is case sensitive) - wlan.exe gp <Interface GUID> <Profile Name>

Thanks again!!

Dewayne

Dewayne Cudney

+1
Login to vote
tomssd's picture

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
Download:
http://www.symantec.com/connect/sites/default/file...
Command Switches Info:
http://www.symantec.com/connect/articles/how-captu...)

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)
4. CAPTURE THE GUID:
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.

6. CAPTURE the CONFIG:
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.”

8. SCRIPT the DELPOY:
Now it is time to write the files that will be used for the deploy piece. Follow steps below
8a. **IMPORTANT** ALL files need to be in the same folder when the VBS script is ran
8b. In the folder, create a batch file named create.bat with the wlan.exe ei command in it.
Command to put in the batch file: wlan.exe ei > interface.txt

8c. Copy the wlan.exe and config xml file into the folder
8d. Create a vbs script with the code below. You can name the script whatever you want, again I named it the SSID for Identifications purposes.
Note that profile.xml will have to be named whatever your xml file is and the last line of code can say anything you want.
The Asterisks at the beggining and end of the code snippet are not part of the script, they are markes to show you the code.
********VBS Script Start********
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set MyFile = objfso.CreateTextFile("wlan.bat", True)
Set shell=createobject("wscript.shell")

Shell.run ("create.bat")
wscript.sleep 5000

Set objTextFile = objFSO.OpenTextFile("interface.txt", ForReading)

For i = 1 to 2
objTextFile.ReadLine
Next

strLine = objTextFile.ReadLine
strMid = mid(strLine,8)

MyFile.WriteLine("wlan.exe sp" & " " & strMid & " " & "profile.xml")
MyFile.Close
objTextFile.Close

Shell.run "wlan.bat"
wscript.sleep 5000
set shell=nothing
Set DFile = objfso.GetFile("wlan.bat")
Dfile.Delete
Set DFile2 = objfso.GetFile("interface.txt")
Dfile2.Delete
Wscript.echo "Wireless has been configured!"
********VBS Script End********

9. RUN the SCRIPT:
At this point, you should have 4 files in your folder. Create.bat, profile.xml, wlan.exe, and script.vbs. Run the script.vbs to deploy/build the
profile on the target computer. All settings should be retained and be good to go. I have the script create 2 files during the process and delete them
when it finishes as they are specific to the computer it is ran on.

10. If you have multiple SSIDs you would like to configure, you will have to repeat the process for each SSID. I managed to create 3 different
ones and then put all the files in the same folder and then just run which ever script i need to use to configure. I am sure it could be modified
to do it all from one script, but I did not have a need for that and since the scripts only take a few seconds to run if you had to run multiples,
it would not be the end of the world.

+1
Login to vote
akoutsouradis's picture

Has anyone been able to get this to work with profiles that use PEAP authentication?  I get the following error message when exporting any PEAP profile:
The parameter for "gp" is not correct. Please use "help gp" to check the usage of the command.
Other profiles work just fine with exports and imports.

0
Login to vote
Pigeo's picture

(Tested under Windows XP)

If you try to export a profile that uses PEAP (or other kind of EAPs) authentification, it displays the following error message : The parameter for "gp" is not correct. Please use "help gp" to check the usage of the command.

Here's a trick I've found : 

1) open regedit and go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\{your_interface_GUID}\ : Here you'll find different entries, numbered sequencially from 1 to XXX. Double click on each of these entries in order to display their content in a readable form. Locate the entry where your profile name is mentioned somewhere in the beginning of the binary date (there should be only one entry in this case). Export this entry in a .REG file. Note : the entry name (which is a number between 1 and 99) has no importance at all : you can safely give it any number from 1 to 99. So, in order not to overwrite another existing profile on another computer, let's rename it 99.

2) modify your profile before exporting it : go to profile properties, tab "authentification", and as EAP type, choose "Smartcard or other certificate" (sorry if translation is bad... I'm on a French version of Windows) then OK.

3) export your modified profile. Since it no longer uses a PEAP, you can export it without error message.

4) import the modified .REG file in order to restore your wifi profile to its original EAP type settings.

5) optionnal : You can reopen Wifi Profile settings in order to check that the EAP type settings has been correctly restored by the importation of the .REG. If it's not the case, don't panic: it may require some reboot or service start / stop or importing a profile with WLAN so that the "new" parameters are taken into account.

To import the profile on another computer :

1) import the modified profile using WLAN.exe

2) then, import the modified .REG in order to restore the EAP type settings

3) Maybe some reboot or service start / stop or importing another profile using WLAN is required in order to "update" and so that new parameters are taken into account by Windows (though I'm not sure if this is actually required)

0
Login to vote
GarryShape's picture

I run into a problem with this method.

After you import the profile with WLAN.exe, it creates a wireless REG_BINARY entry in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces.

So now when you import the reg file, it doesn't replace the registry entry, it adds yet another REG_BINARY for the same wireless network. So you still have to delete the generated REG_BINARY item that came after the WLAN import, and then your EAP type settings will take effect immediately. 

How would one even automate that? 

0
Login to vote
jaylweb's picture

Seems very sloppy to call batch files to launch a command line application for a vbscript.  Yes it works, but can be much simpler with a single batch file instead of two batch files and a vbs.  Not to mention, you can parse the output of wlan.exe ei using the For /F command without creating a temporary text file.

Here is what I created.  Name the BAT after your SSID and you won't have to edit this script at all. (%~n0 calls the BAT name without the extension)  The echo statements are optional, but makes it nice to know what is happening.  The pause script is optional as well depending on how you plan to deploy. 

Save the following as a BAT or CMD file.  Do not copy the lines with asterisks. 

********BAT Script Start*******
@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.
echo SSID: %~n0 has been configured!
pause
********BAT Script End*******

Enjoy!

+2
Login to vote
jaylweb's picture

This BAT/CMD is simpler.  You only need to place this BAT in the same folder as your XML's.  Make sure the XML's are named after the SSID.  This BAT will add all SSID's (the XML's) to your wireless card.  The BAT file can be named to whatever you like.  

********BAT/CMD Script Start*******
@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

For %%i in (*.xml) do (
    echo Adding wlan SSID %%~ni
    wlan.exe sp %Interface% %%i

    echo.
    echo SSID: %~ni has been configured!
    echo.
    echo.
)
********BAT/CMD Script End*******

Enjoy!

+2
Login to vote
Frank019's picture

Thanks that could be very useful

0
Login to vote
beach's picture

Hi there,

This looks like the exact same program as the WindowsSDK sample for the WirelessAPI.  In which case at the top of the source code it's copyrighted by Microsoft.

Just thought people should know if they are using it for something other than personal use. 

0
Login to vote
SK's picture

The download link for the tool is a Microsoft link so anyone who uses this tool will know that it belongs to Microsoft.

SK

Connect Etiquette: "Mark as Solution" those posts which resolve your problem, and give a thumbs up to useful comments, articles and downloads.

0
Login to vote
perrin_wolf's picture

THANK YOU  jaylweb, and tomssd.  As a scripting newbie seeing both methods was very helpful.

the script is working great, and with PEAP Authentication, using a PKI cert.

0
Login to vote
CCavazos's picture

When I try to import the profile I get an error, "The given profile is not vaild."  I created the profile several times using the method described above and I still receive the same error.  Has anyone else experienced this?

0
Login to vote
cmacrun's picture

@CCavazos-

Did you open the XML you exported and remove the first and last lines, making it a valid xml file?  I missed this step at first but once you edit the xml, you should be good.

0
Login to vote
mike_plichta's picture

I've got an HP 4415s laptop that fails on the gp export step.  I was able to get it to list the profiles so I know I have the GUID typed in correctly.  If I ask for the settings from the ssid (it's all numbers so there is no case sensitivity problem) it throws the error in the subject line.  If I ask for an SSID that doesn't exist, it gives a different error code 1168.  

This is a broadcom 4322AG card a/b/g
 

0
Login to vote
campbellm's picture

Not having any luck setting the profile order using wlan spl <GUID> <profile name>+

I have tried many variations and the syntax is not entirely clear. Do you enter each profile name, in the order you want them, separated by a + sign ? I've tried everything I can think of, something is missing.

0
Login to vote
jaylweb's picture

beach,
This utility is available by download from Microsoft,s site.  If there were a licensing issue, it wouldn't be freely available to the world for download. 

campbellm,
I don't believe you can enter multiple profiles in the way that you are trying.  You can import using only one xml file at a time.  The examples that I provided were using an XML file for each profile and basically using wlan to import them one at a time.  I believe you can import multiple profiles using one XML file, including the preference order.  It has been a while since I was using this utility, so you'll have to test it out and play with it.  If you still have problems figuring it out, then I might be able to help you on Monday.

Command: GetProfileList(gpl)
Description: Get the list of saved profiles, in the preference order.

mike_plichta,
I'm not even sure how what command and parameters you are running that generates the error.  I'm guessing it is some sort of syntax error?  What OS are you running? A little more insight might help me to help you.  :)

0
Login to vote
campbellm's picture

I figured out how I'm going to handle the profile order using the batch file example by numerically numbering my profiles so that they are process in the order I want.

What I'm running into though is that if a machine has multiple wireless adapters, the batch will only process the GUID for the first adapter it parses. I'm trying to figure out how to batch this so that it will loop through and process the profiles for each wireless adapter until all GUID parsed have had profiles created.

0
Login to vote
jaylweb's picture

Try something like the following batch file.  It is similar to what I posted earlier, except that the next For loop runs within the first.  This way, it will run for each GUID that it finds. 

********BAT/CMD Script Start*******
@echo off

echo Grabbing WLAN Interface...
For /F "skip=2 tokens=1,2" %%A IN ('wlan.exe ei') Do (
    If "%%A"=="GUID:" (
        For %%i in (*.xml) do (
            echo Adding wlan SSID %%~ni
            wlan.exe sp %%B %%i

        echo.
        echo SSID: %~ni has been configured!
        echo.
        echo.
    )
)
********BAT/CMD Script End*******

+1
Login to vote
JuliusPIV's picture

I'm looking for a solution like this for Windows 7 as I'm trying to find a way to deploy or automate the process of adding pre-configured wireless profile.  Although I successfully exported the profile from a previously configured machine via
netsh wlan export profile name="company-network" folder="H:\wireless-profile"

When I import the profile using netsh, it does not include the WPA2PSK TKIP key.
netsh wlan add profile filename="H:\wireless-profile\weth0-company-network.xml" user=all

So I decided to try my hand at creating a GPO (Computer Configuration > Windows Settings > Security Settings > Wireless) by importing the XML file created above, but when I import the XML above, I receive a "The Network Key has been removed from this profile" message.  This happens even when I set <protected>false</protected> and include the key unencrypted (<keyMaterial>UNENCRYPTED</keyMaterial>)

Lastly, I'm aware that Windows allows one to copy an already configured wireless profile to a USB flash drive, but its my understanding that the `setupSNK.exe` that gets created doesn't accept any of the standard silent/quiet switches.  Furthermore, the file won't even launch when its not run from a flash; it simply doesn't launch or it launches and immediately quits.

How can I silently deploy a pre-configured wireless profile?
Can this be done via VBScript or PowerShell?
Or am I forced to use something like zwlancfg?

0
Login to vote
phil26271's picture

Julius, did you find a solution to reploying pre-configured wireless settings ?  Thanks.

0
Login to vote
mtroelsen's picture

Hey all

just found out how to import a profile into a Windows 7 machine using the netsh wlan built in command line tool, based on the experiences I had with the article posted here.

Unfortunately, it is not completely hassle free. A little background story:

After testing for some time, I found that exporting and importing a profile using the netsh wlan command, built into Windows vista and upwards, works fine when you do it on the same machine. However, take that very same XML file over onto another pc, and it won’t work... the passphrase simply doesn't get imported.

With this in mind, I looked at the old XML file made using the WLAN tool from this article, and i found that the only difference is in the sharedkey section at the bottom. The main difference was that the key exported using the tool from this article was a "networkKey" keytype, the keytype of the one exported using the built in tool in Windows 7 was "passphrase". This got me thinking...  What if I took the whole sharedkey section from my XML file generated by the WLAN tool in Windows XP... would that work?

The answer.... is YES! It did!

For some odd reason, the encryption algorithm for Windows 7 for the wireless profiles is so weird that its key is restricted to that one machine.

Answer to your prayers is the following

1) Download the WLAN tool from this article onto a Windows XP machine with your wireless profile already set up
 
2) Export the profile into a XML file using the guide from this article. Notice that the sharedkey section should say "networkKey" as keytype and it says false in protection.

3) Import the XML file into your Windows 7 machine using the following command

netsh wlan add profile filename="c:\my wireless key\wirelesskey.xml"

And that’s basically it!

Since netsh is a built in command in Windows 7, there is a ton of ways to automate it for your domain.yes

 Happy WLAN deploying! smiley

+3
Login to vote
jaylweb's picture

mtroelsen, that is a great find!  Did you find a way to export from a Win7 and import into another Win7?  Your method for exporting from WinXP and importing to Win7 is sound.  But I think Win7 to Win7 will be the next evolution.  laugh

+1
Login to vote
mtroelsen's picture

Hey Jaylweb

Unfortunately no, but i haven't given up yet. Everything is possible...

One added "bonus" to doing it the way i described (importing the profile from XP into Win7), is that if you try to have a look at your wireless key (in the profile settings itself, go to the "security" tab), it will show as ew9ijwe9fjw9+efjw+e9f8jw+e9fjw9+efj or whatever your key was previously encrypted into in Windows XP. This however posts a new challenge... since what im ultimately interested in is having a XML file on my network for deployment, which users cant read anything in, should they intercept the file.

I will give an example on this

The XML file i currently have from XP (the one that works for importing in Win7), shows the following settings under the "sharedkey"  section:

keytype = networkkey
protected = false
keymaterial = 26BAD0FE231492A42F2C51D51DA1F272184E150

Lets say my cleartext password for the network is "myhorseisapony", then that keymaterial would resemble a "encrypted" version of it. BUT for some odd reason, the "encrypted" key ALSO works if you punch that in while connecting... this is... uhm... rather not good :) It would mean that if my users got a hold of the XML file it might as well say the password in cleartext. So.... this means i am one step closer to the ultimate solution, but not quite there yet. At least now we can deploy the profile.

EDIT: The keymaterial from the Windows XP export is hex code! How did i not notice that at first :) Maybe this can point me towards something.

For good measure, should you want to contact me for any reason, i can be reached at support AT madstroelsen DOT dk (replace the AT with @ and the DOT with .)

But otherwise trust me... as soon as i know, YOU guys will know :)

Have a great week all

+1
Login to vote
cobmsdn's picture

1.) Configure an SSID & export using an XP workstation as described earlier.

2.) Create a PowerShell script with the following code:

- - - code - - -
[array] $interfaces = & "C:\Temp\wlan.exe" ei;

foreach ($item in $interfaces) {
     if ($item.Trim().Contains('GUID:')) {
          [string] $guid = $item.Trim().Substring(6);

          Write-Host "Adding SSID: 'MySSID'";
          & "C:\Temp\wlan.exe" sp $guid "C:\Temp\Source\MySSID.xml" | Out-Null;
      }
}
- - - code - - -

+2
Login to vote
mtroelsen's picture

Finally! After much blood, sweat and tears... here is a viable way to export from Win7, and reimport into Win7.

Took me some time to find, but here is the official documentation from Microsoft about their whole programming library for WLAN profiles:

http://msdn.microsoft.com/en-us/library/ms706965(v=VS.85).aspx

What I basically found out from that site, is that the only way for you to import a wireless profile from one PC to another PC (possibly of a different make and model), is to have the passkey unencrypted in the XML file. You can read it at the bottom of this page:

http://msdn.microsoft.com/en-us/library/aa370032(v=VS.85).aspx

So... the way to export is this way:

netsh wlan export profile name="my first wireless" folder="c:\wireless" key=clear

That string, produces an XML file, where the sharedkey section should say keytype=passPhrase , protected=false and keyMaterial= your unencrypted wireless key

This XML file, is good for being imported to whichever Win7 machine you want to use it on. Just remember that the wireless key is stored unencrypted, and take appropriate measures towards not sharing this XML file with all your users (if you want to keep it secret).

Next, the way to import the same profile again is this:

netsh wlan add profile filename="c:\wireless\myfirstwireless.xml"

Just remember, if you want to export the profile without needing to change anything in it, use my above export string. If you don’t type in key=clear at the end, the key will be encrypted, and you won't be able to import it again on another PC other than the one you currently exported it from.
 

+2
Login to vote
NoJacket31's picture

Am getting errors when i try to capture a profile with WPA2 security but it okay when i capture WEP security profile. Can capture successfully on Windows 7 without a problem but my problems are on Windows XP with SP3. Has anyone come across this error in the subject line....

0
Login to vote
jaylweb's picture

NoJacket31,

Another user had posted that same error and I had suggested it might have been a syntax error, but they never responded.  Can you copy/paste your syntax for us to see?  That would be helpful.  Also, is the key all numbers?  Curious since the prior person mentioned thier key was all numbers.  I'm not sure what the smoking gun is yet, but we can help you figure it out.  :)

jaylweb

0
Login to vote
bobhoskins's picture

jaylweb - awesome stuff, great script. I've tested the xp one, works fine. Just about to test on SP2 also...hoping that we don't have to insall anything but i take your earlier comment on that.

Will be testing the Win7 one at some point as well but it looks like you've cracked that one also.

Really good stuff for the community well done - BOOKMARKED!

Symantec don't you dare lose this page....

+1
Login to vote
bobhoskins's picture

Nah SP2 does require that KB article referenced and the required patch installed. Runs fine after that. Next test, Win7! We've got em all you see....:)

0
Login to vote
rustychiles's picture
I needed to automate wlan profiles post-os deployment in systems with a single WLAN card and some of the batch examples didn't seem to work for me so I came up with this to find the GUID then deploy my settings. If it helps anybody else I figured i'd share. 
 
For /F "tokens=1-2*" %%A IN ('wlan.exe ei ^| find "GUID:"') do set WLGUID=%%B
wlan.exe sp %WLGUID% wlan.xml
0
Login to vote
gagaduckula's picture

I've got a profile xml file from Win7

It's normal if I use netsh wlan in Win7.

How can I use it in WinXP for wireless setup?

It looks to use command wlan conn <interface GUID> <SSID> <infrastructure(i)|adhoc(a)> <profile name>

However I am not sure what's the infrastructure|adhoc mean.

Anyone could teach me??

Thanks a lot.

0
Login to vote
jlawson's picture

Looking through this article because I now need to start getting a method for Windows 7.  I have always used AutoIT in xp to deploy my wireless setup but this does not work in Windows 7.

First I would like to suggest everyone please vote up this idea:

https://www-secure.symantec.com/connect/ideas/create-wifi-network-connection-job-or-task

+1
Login to vote
questorfla's picture

i have the complete and working batch file for using XML and it works to export as well as import.

But

I have yet to test on cross/system.  This is tested only on my own laptop.  Export/ Delete/ check to make sure not there/ import from XML

Works fine.  But.  This, as you say, is not worth anythign it it wont cross/system deploy.

Plus XML files (as well as rthe WFC file created when you use the windows 7 built in export for import to new system) are both plaintext.  Not good.

Has anyone looked at doing a registry export?  I ran acroos (by accident) the location of these keys one day when I was trying to totally TOTALLY remove some mapped network drives.  Windows 7 refuses to "forget" the path even when disconnected for weeks.  The drives will even remap to a new IP but the IP shown in the COMPUTER display more than not shows the OLD IP even thougfh it is connected to a NEW IP.

This is a compltely different problem I am working on as well but this deployment of WIFI profiles I need to get done ASAP.

Thanks for any input

I tried to allow replies to my posts if it doesnt work I will send my email address to you

0
Login to vote
GraceSolutions's picture

I came up with the following script for myself and those who are in the "Organizations who STILL need to upgrade from Windows XP" boat

Usage:

cscript.exe "ConfigureWirelessSettings.vbs" /Retrieve

Or

cscript.exe "ConfigureWirelessSettings.vbs" /Restore

Ultimately, this script will make use of the "WLAN.exe" tool on Windows XP and make use of the "netsh.exe" tool in Windows Vista and later in order to export all wireless profiles to a flash drive in a folder called "Backup\NameOfComputer\WirelessProfiles". Each Profile will be named as the "SSID.xml" You may then use the restore functionality to import all retrieved profiles back into the system.

Modify the "WirelessProfileDestinationFolder" variable in order to change the backup location to whatever your needs are. Example: (Network Location, Local Disk, etc...)

Hope this helps somebody!

'Define Target Computer
strComputer = "."

'Set object values
Set oArguments = WScript.Arguments.Named
Set oFSO = CreateObject("Scripting.FileSystemObject") 
Set oShell = CreateObject("WScript.Shell")
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\CIMV2")

'Define ASCII Characters
chrSpace = Chr(32)
chrSingleQuote = Chr(39)
chrDoubleQuote = Chr(34)

'Define Folder Locations
WorkingDir = oFSO.GetParentFolderName(WScript.ScriptFullName)

'Gather information from WMI

'Query # 1 - Gather information about the device from the "Win32_ComputerSystem" class
Set oComputerSystem = oWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem")
	For Each oItem In oComputerSystem
		strUserName = oItem.UserName
		strComputerName = oItem.Name
Next

'"oItem.UserName" places the computer name and a "\" before the username, so time to manipulate the string
'Remove all text before the "\" so just the username of the currently logged in user is left
If InStr(strUserName, "\") > 0 Then
	strUserName = Mid(strUserName, InStr(strUserName, "\") +1)
End If

'Query # 2 - Determine Operating System Version
Set oOperatingSystem = oWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem") 
For Each oItem in oOperatingSystem
    strOSVersion = oItem.Version
Next

'Gather the GUID of the Wireless Network Connection
If (strOSVersion >= "5") And (strOSVersion < "6") Then
'Execute "Wireless Local Area Network Tool" "ei" (Enumerate Interfaces) command > Provided free by Symantec
	Set GetWirelessGUID = oShell.Exec(chrDoubleQuote & WorkingDir & "\Tools" & "\WLAN.exe" & chrDoubleQuote & chrSpace & "ei")	
'Read the output from the command
	Do Until GetWirelessGUID.StdOut.AtEndOfStream
		InterfaceGUIDs = Split(GetWirelessGUID.StdOut.ReadAll, vbCrLf)
	Loop
'Parse and modify the command output so that only the GUID remains
	'Begin a "For Loop"
		For Each GUID In InterfaceGUIDs
		'Determine if the string "GUID: " is inside of one of the returned lines
			If InStr(GUID, "GUID: ") > 0 Then
			'Remove any tabs from the returned string
				strGUID = Replace(GUID, vbTab, "")
			'Remove the first 7 characters from the returned string (" GUID: ")
				strGUID = Right(GUID, Len(GUID) - 7)
			'Uppercase the returned string
				strGUID = UCase(strGUID)
			End If
			If Not (strGUID = "") Then
				WirelessInterfaceExists = "True"
			Else
				WirelessInterfaceExists = "False"
			End If						
		Next
'Query # 3 - Gather information about the device from the "Win32_NetworkAdapter" class					
ElseIf (strOSVersion >= "6") Then
	Set oNetworkAdapter = oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID Like '%Wireless%'")
		If oNetworkAdapter.Count > 0 Then
			WirelessInterfaceExists = "True"
				For Each oItem In oNetworkAdapter
					strGUID = oItem.GUID
					strGUID = Replace(strGUID, "{", "")
					strGUID = Replace(strGUID, "}", "")
				Next
		Else
			WirelessInterfaceExists = "False"		
		End If
End If

'Determine information about various disks
Set oDrives = oFSO.Drives
For Each oDrive In oDrives
	'Determine atrributes of the first detected removable drive
	If (oDrive.DriveType = "1") Then
			DestinationDriveLetter = oDrive.DriveLetter & ":"
			DestinationVolumeLabel = oDrive.VolumeName
			DestinationFreeSpace = Int(oDrive.FreeSpace / 1048576)		
		Exit For 
	End If
Next

'Define destination folder location
	WirelessProfileDestinationFolder = DestinationDriveLetter & "\Backup\" & strComputerName & "\WirelessProfiles"

'Gather the wireless profiles on the device and export them
	If oArguments.Exists("Retrieve") And (strOSVersion >= "5") And (strOSVersion < "6") And (WirelessInterfaceExists = "True") Then
'Execute "Wireless Local Area Network Tool" "gpl" (Get Profile List) command > Provided free by Symantec
	Set EnumerateWirelessProfiles = oShell.Exec(chrDoubleQuote & WorkingDir & "\Tools" & "\WLAN.exe" & chrDoubleQuote & chrSpace & "gpl" & chrSpace & strGUID)	
		'Read the output from the command
		Do Until EnumerateWirelessProfiles.StdOut.AtEndOfStream
			'Split the output into lines so it can be sorted easier
			WirelessProfiles = Split(EnumerateWirelessProfiles.StdOut.ReadAll, vbCrLf)
		Loop
'Create a counter that will be incremented with each iteration of the loop
	ArrWirelessProfilesCounter = 0
'Begin the "For Loop"
	For Each WirelessProfileName In WirelessProfiles
	'Remove double quotes from any WirelessProfile
		WirelessProfileName = Replace(WirelessProfileName, chrDoubleQuote, "")
    'Remove indentation/tabs from any WirelessProfile
    	WirelessProfileName = Replace(WirelessProfileName, vbTab, "")
    'Remove the first line from the command output that reports the amount of profiles on the system
    	If InStr(WirelessProfileName, "There are ") > 0 Then
    		WirelessProfileName  = ""
    	End If
    'Remove the last line from the command output that reports that the command was completed successfully
    	If InStr(WirelessProfileName, "Command ") > 0 Then
    		WirelessProfileName  = ""
    	End If
	'Create a self building array with each result from the "For Loop"
		ReDim Preserve arrWirelessProfiles(ArrWirelessProfilesCounter)
		arrWirelessProfiles(ArrWirelessProfilesCounter) = WirelessProfileName	
	'Only increment the counter if the result from the "For Loop" is not blank or Null
		If Not (WirelessProfileName = "") Or IsNull (WirelessProfileName) Then
			'Create the folders that are needed to export the profiles
				If Not oFSO.FolderExists(WirelessProfileDestinationFolder) Then
					MakeWirelessProfileFolder = oShell.Run("cmd.exe /c mkdir" & chrSpace & chrDoubleQuote & WirelessProfileDestinationFolder & chrDoubleQuote, 0, True)
				End If
			'Execute "Wireless Local Area Network Tool" "gp" (Get Profile) command > Provided free by Symantec
				Set GetWirelessProfiles = oShell.Exec(chrDoubleQuote & WorkingDir & "\Tools" & "\WLAN.exe" & chrDoubleQuote & chrSpace & "gp" & chrSpace & strGUID & chrSpace & chrDoubleQuote & WirelessProfileName & chrDoubleQuote)
			'Read the output from the command
				Do Until GetWirelessProfiles.StdOut.AtEndOfStream
					WirelessProfileSettings = GetWirelessProfiles.StdOut.ReadAll
				Loop	  				
			'Export each profile to a ".xml" file with the SSID as the filename	
					Set ExportWirelessProfiles = oFSO.CreateTextFile(WirelessProfileDestinationFolder & "\" & WirelessProfileName & ".xml")
						ExportWirelessProfiles.Close
						Set ExportWirelessProfiles = Nothing
					Set ExportWirelessProfiles = oFSO.OpenTextFile(WirelessProfileDestinationFolder & "\" & WirelessProfileName & ".xml", 2)
						ExportWirelessProfiles.Write(WirelessProfileSettings)
						ExportWirelessProfiles.Close
						Set ExportWirelessProfiles = Nothing
			'Increment the counter for the next iteration of the loop
				ArrWirelessProfilesCounter = ArrWirelessProfilesCounter + 1
			End If
		Next
			ElseIf oArguments.Exists("Retrieve") And (strOSVersion >= "6") And (WirelessInterfaceExists = "True") Then
				'Create the folders that are needed to export the profiles
					If Not oFSO.FolderExists(WirelessProfileDestinationFolder) Then
						MakeWirelessProfileFolder = oShell.Run("cmd.exe /c mkdir" & chrSpace & chrDoubleQuote & WirelessProfileDestinationFolder & chrDoubleQuote, 0, True)
					End If
				'Use "netsh" in order to automatically export all wireless profiles
					strExportWirelessProfiles = "netsh.exe wlan export profile folder=" & chrDoubleQuote & WirelessProfileDestinationFolder & chrDoubleQuote & chrSpace & "key=clear"
					comExportWirelessProfiles = oShell.Run(strExportWirelessProfiles, 0, True)
				'Replace the backslashes in the destination path string with two backslashes so it can be used properly in the following WMI query
					WirelessProfileDestinationFolder = Replace(WirelessProfileDestinationFolder, "\", "\\")
				'Remove the drive letter from the string so it can be used properly for the following WMI query
					WirelessProfileDestinationFolder = Right(WirelessProfileDestinationFolder, Len(WirelessProfileDestinationFolder) - 2)				
				'Query to find out how many profiles were exported to the destination folder
					Set oWirelessProfiles = oWMI.ExecQuery("SELECT * FROM CIM_DataFile WHERE Path = " & chrSingleQuote & WirelessProfileDestinationFolder & "\\" & chrSingleQuote & " And Drive = " & chrSingleQuote & DestinationDriveLetter & chrSingleQuote & " And Extension Like '%xml%'")
					'Only take action if there were results
						If oWirelessProfiles.Count > 0 Then
						'Begin "For Loop" to go through each result and remove the "Wireless Network Conntection-" prefix from each file name, thus only leaving the wireless SSID as the filename
							For Each oWirelessProfile In oWirelessProfiles
								NewWirelessProfileName = Replace(oWirelessProfile.FileName & "." & oWirelessProfile.Extension, "Wireless Network Connection-", "")
								RenameWirelessProfile = oShell.Run("cmd.exe /c rename" & chrSpace & chrDoubleQuote & oWirelessProfile.Name & chrDoubleQuote & chrSpace & chrDoubleQuote & NewWirelessProfileName & chrDoubleQuote, 0, True)
							Next
						End If
			End If
			
			'Restore the wireless profiles that have been retrieved
				If oArguments.Exists("Restore") And (strOSVersion >= "5") And (strOSVersion < "6") And (WirelessInterfaceExists = "True") Then
			'Replace the backslashes in the destination path string with two backslashes so it can be used properly in the following WMI query
					WirelessProfileDestinationFolder = Replace(WirelessProfileDestinationFolder, "\", "\\")
				'Remove the drive letter from the string so it can be used properly for the following WMI query
					WirelessProfileDestinationFolder = Right(WirelessProfileDestinationFolder, Len(WirelessProfileDestinationFolder) - 2)				
				'Query to find out how many profiles were exported to the destination folder
					Set oWirelessProfiles = oWMI.ExecQuery("SELECT * FROM CIM_DataFile WHERE Path = " & chrSingleQuote & WirelessProfileDestinationFolder & "\\" & chrSingleQuote & " And Drive = " & chrSingleQuote & DestinationDriveLetter & chrSingleQuote & " And Extension Like '%xml%'")
				'Only take action if there were results
					If oWirelessProfiles.Count > 0 Then
				'Begin "For Loop" to go through each result and use "netsh" in order to import each wireless profile
					For Each oWirelessProfile In oWirelessProfiles
						strImportWirelessProfile = chrDoubleQuote & WorkingDir & "\Tools" & "\WLAN.exe" & chrDoubleQuote & chrSpace & "sp" & chrSpace & strGUID & chrSpace & chrDoubleQuote & oWirelessProfile.Name & chrDoubleQuote
						comImportWirelessProfile = oShell.Run(strImportWirelessProfiles, 0, True)
					Next
					End If
			ElseIf oArguments.Exists("Restore") And (strOSVersion >= "6") And (WirelessInterfaceExists = "True") Then
				'Replace the backslashes in the destination path string with two backslashes so it can be used properly in the following WMI query
					WirelessProfileDestinationFolder = Replace(WirelessProfileDestinationFolder, "\", "\\")
				'Remove the drive letter from the string so it can be used properly for the following WMI query
					WirelessProfileDestinationFolder = Right(WirelessProfileDestinationFolder, Len(WirelessProfileDestinationFolder) - 2)				
				'Query to find out how many profiles were exported to the destination folder
					Set oWirelessProfiles = oWMI.ExecQuery("SELECT * FROM CIM_DataFile WHERE Path = " & chrSingleQuote & WirelessProfileDestinationFolder & "\\" & chrSingleQuote & " And Drive = " & chrSingleQuote & DestinationDriveLetter & chrSingleQuote & " And Extension Like '%xml%'")
				'Only take action if there were results
					If oWirelessProfiles.Count > 0 Then
				'Begin "For Loop" to go through each result and use "netsh" in order to import each wireless profile
					For Each oWirelessProfile In oWirelessProfiles
						strImportWirelessProfile = "netsh wlan add profile filename=" & chrDoubleQuote & oWirelessProfile.Name & chrDoubleQuote & chrSpace & "user=all"
						comImportWirelessProfile = oShell.Run(strImportWirelessProfile, 0, True)
					Next
					End If
			End If
AttachmentSize
ConfigureWirelessSettings.zip 2.91 KB
0
Login to vote