none
Automate join to wifi network? RRS feed

  • Question

  • We will be imaging about 100 laptops this summer with Win7. We do this imaging on a hard wired connection. We have a wifi network and use WPA2-PSK. I would like some way to automate the joining of these laptops to our wifi network. I would rather not have to manually join each laptop and type in a long key each time.

    Is there some way of doing this via sysprep? script that runs on first startup? group policy (we do have a Windows Server 2008 R2 domain)?

    Saturday, April 3, 2010 12:59 PM

Answers

  • You could do like this:

    netsh wlan export profile name="NameOfWirelessNetwork" folder=c:\temp interface="Wireless Network Connection"

    to export all settings related to that wireless network. And then run the following command to import it automatically during installation by creating a "run command" in the unattended answer file or in the task sequence if you are using MDT2010.

    netsh wlan add profile filename="\\server\share\wlanconfig\Wireless Network Connection-NameOfWirelessNetwork.xml"


    Blogging about Windows for IT pros at www.theexperienceblog.com
    • Marked as answer by HendersonD Wednesday, April 7, 2010 7:23 PM
    Sunday, April 4, 2010 7:31 AM

All replies

  • You could do like this:

    netsh wlan export profile name="NameOfWirelessNetwork" folder=c:\temp interface="Wireless Network Connection"

    to export all settings related to that wireless network. And then run the following command to import it automatically during installation by creating a "run command" in the unattended answer file or in the task sequence if you are using MDT2010.

    netsh wlan add profile filename="\\server\share\wlanconfig\Wireless Network Connection-NameOfWirelessNetwork.xml"


    Blogging about Windows for IT pros at www.theexperienceblog.com
    • Marked as answer by HendersonD Wednesday, April 7, 2010 7:23 PM
    Sunday, April 4, 2010 7:31 AM
  • Thanks, the netsh command worked great with one tweak. I can export the wireless configuration fine but when I imported it to another machine it keeps prompting to enter the WAP2 key. I opened the xml file that was exported and noticed that the key was encrypted. I changed this line to false:

    <protected>false</protected>

    and then put in the unencrypted WPA2 key. It imports fine now and joins the laptop to the wireless network. The xml file that I wrote out will be kept in a safe spot so I am not worried about someone else finding out the key.

    I ran this netsh wlan add.... from a SetupComplete.cmd in the c:\Windows\Setup\Scripts folder. I think this script runs just once and first joins the wifi network and then deletes things like my unattend.xml file.

    I would like to use the same scripts and unattend file for all of my machines. What happens if the netsh wlan add... command is run on a desktop computer that does not have a wireless nic? Will it just fail and there are no consequences?

     

    Tuesday, April 6, 2010 8:57 PM
  • Hi,

     

    By default, the Wireless AutoConfig Service is stopped on the Desktop which does not have Wireless NIC. Hence, the command will just be failed.

     

    Thanks,

    Novak

    Wednesday, April 7, 2010 6:47 AM
  • That is good news. I would rather not have to make separate setups for laptops versuse desktops
    Wednesday, April 7, 2010 4:43 PM
  • HendersonD,

     

       Thanks.  That was driving me crazy.  That worked.  Now if we can find a way to get rid of IPV6, QOS and F&P sharing through a script we will be fine.  Thanks again.

    Tuesday, July 6, 2010 3:13 PM
  • Hi HendersonD,

    My SetupComplete.cmd does not seem to run. The line I have on the file is

    netsh wlan add profile filename="\\nameofmyserver\nameoffolder\nameoffile.xml". Once the workstation is imaged, the file is still in the scripts folder. When I click on it, it joins the wireless network. So I know the file has the correct command. What am I missing?

    I would appreciate your response.

    Thanks.

    Friday, November 19, 2010 1:22 PM
  • Hi, Im doing the same, can you help me?, how did you put the wpa2 key?
    Tuesday, May 19, 2015 8:59 PM
  • you need two commands in the unattend.xml file

    the first command imports the wifi profile as it has been mentioned already, however that doesn't actually connect to the wifi. you need a second one to connect. both are shown here:

                     <SynchronousCommand wcm:action="add">

                      <CommandLine>netsh wlan add profile filename=c:\wifi.xml</CommandLine>

                        <Description>Add Wi-Fi Profile</Description>
                        <Order>1</Order>
                        <RequiresUserInput>false</RequiresUserInput>
                    </SynchronousCommand>
                    <SynchronousCommand wcm:action="add">
                        <CommandLine>netsh wlan connect name=wifi interface=Wi-Fi</CommandLine>
                        <Description>Connect to Wi-Fi</Description>
                        <Order>2</Order>
                        <RequiresUserInput>false</RequiresUserInput>
                    </SynchronousCommand>

    The problem is that it will only work if the password on the xml file is unencrypted. so if your file is unencrypted great, but then you will have to delete the file afterwards if you don't want it to be found by accident.

    I though of adding an additional command to delete the file, but somehow it doesn't work even if you add the "Everyone" user and grant full control to the file. 

    There's another mechanism called the setupcomplete.cmd file but if you attempt to delete the wifi profile there you will find out that the file is going to get deleted before the netsh commands run. So you could either put all three commands in that file, or create a startup script on c:\profiledata\microsoft\windows\start menu\startup that does this, and put a last line to delete itself.

    Thursday, July 11, 2019 9:07 PM