Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm writing a batch script that should connect to a specific wireless network and begin a download from a NAS share drive on that network.

Obviously, before any download can be performed, I must check that the machine is connected to the correct network.

How can I check that I have connected to the correct network?

The relevant section of my batch script is thus:

...

netsh wlan add profile filename=%_SCRIPT_PATH%MyWireless.xml
netsh wlan connect name=MyWireless

...

Where MyWireless.xml is a netsh exported network profile generated by:

C:\Users\Daemon>netsh wlan export profile folder=C:\Users\Daemon\ name=MyWireless
share|improve this question
    
does netsh give you an errorlevel value which you can check in the cmd? –  magicandre1981 Jul 24 '13 at 4:11
    
@magicandre1981 I've just added errorlevel checking, and you are correct, netsh does give an errorlevel value. Do you want to give that as your answer so I can mark it? –  Dæmon Jul 24 '13 at 4:33
add comment

1 Answer

up vote 0 down vote accepted

Check the errorlevel value of the netsh command and handle the result.

http://support.microsoft.com/kb/69576

share|improve this answer
    
Thanks for your help. –  Dæmon Jul 24 '13 at 22:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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