Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Script needed to add a wireless network

Posted on 2008-10-14
Medium Priority
Last Modified: 2016-08-29
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

Question by:johns_ar
LVL 67

Accepted Solution

sirbounty earned 700 total points
ID: 22718392
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,

Author Comment

ID: 22718510
Ok cool thanks very much.

I'll give it a try and report back.


Author Comment

ID: 23654380
This solution half worked but someone else came up with a working script that set everything as it should but only on XP SP3...
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

LVL 67

Expert Comment

ID: 23659593
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.

Author Comment

ID: 23664826
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.
LVL 67

Expert Comment

ID: 23664859
Yes please - I'm sure it can help others with similar needs...

Expert Comment

ID: 24791431
any chance you can share that script?

Expert Comment

ID: 25423171
I would LOVE that script.....

Expert Comment

ID: 25666700
Agreed. I'd like to see the script as well.

Expert Comment

ID: 25762094
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!!

Expert Comment

ID: 25971657
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


Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

DECT technology has become a popular standard for wireless voice communication. DECT devices are not likely to be affected by other electronic devices and signals because they operate in a separate frequency-band.
This program is used to assist in finding and resolving common problems with wireless connections.
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question