Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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? – Taylor Hx Jul 24 '13 at 4:33
up vote 0 down vote accepted

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

share|improve this answer
Thanks for your help. – Taylor Hx Jul 24 '13 at 22:45

Your Answer


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.