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!
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