title: How to create a batch file to map network drives after connected to VPN
body: <p>What is the best method for creating a batch file (.bat) that will automatically map network drives after a internet connection has been established. The batch file will be remain in the windows start up folder and will only map the network drives if they are not already mapped. I have tried the following:</p>
  
  <pre><code>:Start
  ping -n 1 www.google.com
  
  If %errorlevel% == 0 Goto :Start
  
  If %errorlevel% == 1 Goto :Connected
  
  :Connected
  
  Net Use F:\\ Server\Folder /Persistent:No
  </code></pre>
  
  <p>The ping reply is so fast that the Net use command doesn't map the drive even though the path is correct and will work if I manually enter the net use and path in the CMD window. I need for it to wait after the ping reply and then map the network drives and also for it to only map the network drives if they are not already mapped. I realize what I have tried doesn't address the "only map the network drives if they are not already mapped". I have done some extensive searching and I cannot find the answer to these issues. Would appreciate step by step and easy to follow instructions for resolving this.</p>
  
  <p>Thank you very much.</p>