Share via


Add Wifi with batch script

Question

Wednesday, February 3, 2016 1:51 PM | 1 vote

Hello

I have a logon script that I use for my company (yes I know the key is in plain txt, but this is how it is right now)

Most of our users have Windows 7 and the script works fine on those computers, but not in windows 10.

The logon script is this:

IF EXIST C:\WirelessSet3.txt GOTO _END

Netsh wlan add profile filename="\domain.local\netlogon\WiFi.xml" user=all >>C:\WirelessSet3.txt

:_END

The xml file looks like this:

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>WiFi_Name</name>
<SSIDConfig>
<SSID>
<hex>50726F6D657468657573</hex>
<name>WiFi_Name</name>
</SSID>
<nonBroadcast>true</nonBroadcast>
</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>false</protected>
<keyMaterial>WPA2Key</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>

My question is this. Why is it not working on the Windows 10 machines :) 

Any help?

Regards

N.

All replies (7)

Thursday, February 4, 2016 2:14 AM | 1 vote

Hi Trd74,

Have you got any error messages or are there any error messages recorded in the Event Viewer? Did the script work well when we run it manually?

According to my research, it should be available to import the network profile with the command line manually.

We could try to connect to the wireless network then export the network profile on Windows 10 to have a test.

Best regards

Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected].


Thursday, February 4, 2016 8:31 AM | 1 vote

That I could do, and make the same script from my Windows 10 machine. 

-


Thursday, February 4, 2016 2:26 PM | 1 vote

Hi 

I did a small modification off the script:

:CREATES A CHECK VARIABLE

set lookup=0

:CHECKS IF THE FOLDER ALREADY EXIST"

IF EXIST "C:\Wifi\ (set lookup=1)

:IF CHECK is still 0 which means does not exist. It creates the folder

IF %lookup%==0 START "" mkdir "C:\Wifi\

IF EXIST C:\Wifi\Win10.txt GOTO _END

Netsh wlan add profile filename="\atb.local\netlogon\WiFi.xml" user=all >>C:\Wifi\Win10.txt

:_END

To have the .txt file stored in a seperate folder. 

When I run this on a Windows 7 machine, there is no problem. 

When I do it on the Win 10 machine. Nothing happen. When I run the batch manually, the folder is created as it should be....

Why is my Win10 machine not applying the GPO? 


Friday, February 5, 2016 8:31 AM | 1 vote

Hi Trd74,

Are there any error messages recorded in the Event Viewer?

If the script could work well manually, I think it may be related to the permissions or a conflict. We could try to configure it as "startup" script. Or we could create a schedule task to run that script with administrator permissions.

Best regards

Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected].


Wednesday, February 10, 2016 7:00 AM | 1 vote

Hi

No, I cant see any error messages recoreded in teh eevent viewer no... 

How can I run the script with Administrator permissions?

A bit funny - but now I get the cmd windows up- saying "Cant run script, out of memory" 

-Regards


Monday, February 15, 2016 6:16 AM | 1 vote

Hi Narna4Ever,

"A bit funny - but now I get the cmd windows up- saying "Cant run script, out of memory" "
It seems that there is a memory leak bug of the script. We could try to ask for help from our Script Forum to modify the script.
Script Forum
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG

As for the permission, it would run under System account if you configured it as startup script.
If you chosen the task schedule solution, please check the following configurations.

Best regards

Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected].


Tuesday, February 23, 2016 9:39 AM | 1 vote

Hi

Guess we have :) 

I will post it under script forum and see if anyone there can take a look at it :) 

N