• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3989
  • Last Modified:

Script needed to add a wireless network

After searching high and low for something to add a preferred wireless network, along with the WPA key, to multiple XP laptops I found the one on the link below by SirBounty:


Only problem is that it doesn't seem to add the network in the script, or one that I edit in, to my list of preferred networks.

I'm looking for a solution to getting a new network along with the WPA key onto about 500 laptops which are scattered around the British Isles.

Am I doing something wrong !? The script runs, opens the wireless config wizard and then it just sits there as if waiting for me to enter details.  The first time I ran it it stayed on the screen for 5 seconds and disappeared.

Code attached.

Cheers any help appreciated.
SSID="MyTestWIC"  'Adjust to read the SSID
Key="abcdefghijklm" 'Adjust to read the key
Dim objShell:Set objShell=CreateObject("Wscript.Shell")
With objShell
  .Run "control netsetup.cpl"
  wscript.sleep 1000
  .AppActivate "Wireless Network Setup Wizard"
  .SendKeys "%NSN" & SSID & "%MN"
  .SendKeys "%W" & Key
  .SendKeys "%O" & Key
  .SendKeys "%NSN+{Tab}~"
End With
Set objShell=Nothing

Open in new window

1 Solution
Hard to say what the problem is - this isn't so much a script as it is a hack...
What it tries to accomplish is an automated walkthrough thru the wireless network setup.
Line 8 was the working delay for that user, you may need to increase it - it's in milliseconds, so that's about a 1 sec pause.

Try manually stepping through the key sequences.
Click Start->Run->netsetup.cpl <Enter>
??How long do you typically need to wait here??
Longer than 1 sec, increase the timer.

Now hit <Alt> + NSN
You should be at the SSID prompt - enter the network name there and press <Alt> MN (to 'manually' setup the key and 'click' next)
Now hit <Alt> W - type the key
<Alt> O to confirm it
and <Alt> NSN then <Tab> and <Space> (to finish).

Does that work?  What changes were needed?

The underlying problem is, like I said, this isn't really a solution script.  Anyone trying to run this to automate the process should be aware (or at least distracted) that it's running because any user interaction while it's running can take away the focus of the network setup wizard and there's no error trapping involved here - the script would simply fail.

If you're aware of that and finding problems with your personal testing anyway, then the steps above should help identify the problem and hopefully a workaround.

Good luck,
johns_arAuthor Commented:
Ok cool thanks very much.

I'll give it a try and report back.

johns_arAuthor Commented:
This solution half worked but someone else came up with a working script that set everything as it should but only on XP SP3...
We Need Your Input!

WatchGuard is currently running a beta program for our new macOS Host Sensor for our Threat Detection and Response service. We're looking for more macOS users to help provide insight and feedback to help us make the product even better. Please sign up for our beta program today!

Are you asking a question?
Haven't heard anything from you in four months, so I'm not sure what you wanted from me here.
I told you upfront this was more of a hack than a solution, but without your feedback and interaction, there's no way for any expert to determine how to help you.
johns_arAuthor Commented:
Nah I was reporting back saying it was sorted elsewhere.

That hack did work in a fashion, but not as I wanted it to and wasnt really deployable.  Happy to share the script if need be.
Yes please - I'm sure it can help others with similar needs...
any chance you can share that script?
I would LOVE that script.....
Agreed. I'd like to see the script as well.
I know this has been closed, but in case this can help someone here it goes:

In case anyone needs any help with this to do it with a script, since GP is not always a solution here is how i did it:

Download this tool from Symantec it will work on any brand WLAN NIC:
On the page there is help with the commands, but this is step by step how i did it:
OK, first we pull the GUID for the machine to pull from:

C:\WLAN.exe ei
There are 1 interfaces in the system.
Interface 0:
        GUID: 8d91c644-2e6b-46e7-b346-82b7b0f787a9
        Intel(R) WiFi Link 5300 AGN - Packet Scheduler Miniport
        State: "connected"

Command "ei" completed successfully.

Next we will use the GUID we pulled(8d91c644-2e6b-46e7-b346-82b7b0f787a9):

C:\WLAN.exe gpl 8d91c644-2e6b-46e7-b346-82b7b0f787a9
There are 2 profiles on the interface.
Command "gpl" completed successfully.

Next we export the settings from the needed profile, in this case MCSD:

C:\WLAN.exe gp 8d91c644-2e6b-46e7-b346-82b7b0f787a9 MCSD>export.xml

On the target machine the GUID must be queried by using the ei command:

wlan.exe ei

once we have the target GUID we can apply the export file to it:

c:\wlan.exe sp NewGuidFromTarget C:\export.xml

This is the process to complete it, a user naamed tomssd on the Symantec forum where this tool is available from created a script to deploy this to multiple machines, and we verified it works.
Good luck!!
I don't have a vbscript to offer and I know this is under the vbscript forum.  However, vbscript is not the simplest way to do this, which is hard for me to say as I am a vbscript diehard!!  lol

Using wlan.exe mentioned by MCSDexpert above, the following CMD/BAT will added multiple SSID's to a laptop/pc providing the XML is named after the SSID.  See MCSDexpert's post for how to export a config to XML.

@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 SSID: %~ni has been configured!

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now