0

I am trying to write a VBscript that will standardize 50 laptops so they are all have the same configuration of the desktop and delete all personal WiFi profiles and load only the accepted WiFi profiles.

I can easily clean out all the current profiles with the command:

oRem Delete WiFi connections owshShell.Run "netsh wlan delete profile name=*"

I then add the lines to connect to the official SSID's of WORK1SSID and WORK2SSID

oRem Add WORK1SSID and WORK2SSID
owshShell.Run "netsh wlan add profile filename=.\WORK1SSID.XML"
owshShell.Run "netsh wlan add profile filename=.\WORK2SSID.XML"
owshShell.Run "netsh wlan set profleorder name=""""WORK1SSID"""" 
   interface=""""Wireless Network Interface"""" priority=1"
owshShell.Run "netsh wlan set profleorder name=""WORK2SSID"" 
 interface=""Wireless Network Interface"" priority=2"

This works fine to load the profiles but the Laptop still requires the passphrase to be entered.

The XML of the WORK1SSID is as below.

 <?xml version="1.0"?>
 <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>WORKS1SSID</name>
<SSIDConfig>
    <SSID>
        <hex>**************************</hex>
        <name>WORK1SSID</name>
    </SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<MSM>
    <security>
        <authEncryption>
            <authentication>WPA2PSK</authentication>
            <encryption>AES</encryption>
            <useOneX>false</useOneX>
        </authEncryption>
        <sharedKey>
            <keyType>passPhrase</keyType>
            <protected>true</protected>
            <keyMaterial>**********************************************************</keyMaterial>
        </sharedKey>
    </security>
</MSM>

NOTE: I 'made' the .XML file by loading the profile on the Laptop, entered in the key and settings and then did the netsh command to send it over as an XML file to a USB drive.

The * is the numbers of the hex key provided.

I could also try and write a script to delete all the profiles except the ones I want but that would seem harder.

Any help would be appreciated!

2
  • After you run what works with your current stuff [above], add an additional step to run netsh wlan connect ssid="YOURSSID" key="YOURPW" See if that helps you, thanks to my Google Kung Fu.... Soooeeyyy!!! Admin elevated command prompt may be required.... test, test, and test some more while you are at it!!! – Drink More Pimp Juice IT Mar 1 '19 at 20:14
  • Your Kung Fu is way way better than mine, but in this case I dont think it would be needed. Often I would be doing the updates when the work SSID would not be nearby so not much point in making the laptop search for a SSID that isnt there. But by making it a priority connection, it will seek it out when it does become available! – DKeeler Mar 4 '19 at 20:00
0

You can’t move an encrypted pass phrase from a WiFi profile from one computer to another.

Change this code:

<protected>true</protected>
<keyMaterial>**************</keyMaterial>

To:

<protected>false</protected>
<keyMaterial>YourWifiPassphrase</keyMaterial>
2
  • That did it! My mistake to forget to switch from true to false.... Thanks for spotting it for me! – DKeeler Mar 4 '19 at 19:58
  • @DKeeler it would be great if you accepted this as an answer and upvoted. That helps to increase my reputation. – Appleoddity Mar 4 '19 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.