title: Batch file to map network drive
body: <p>I need to create a bat file that will check availability of a drive letter and map the share folder on a free drive letter.</p>
  <p>I tried to work something with an IF condition, but this prone to several drives mapping if the user launch it several time.</p>
  <p>Can anyone help on how to use a FOR loop for this?</p>
  <pre><code>if not exist U:\ (
      net use U: \\test\branchshare$
  exit
  )
  elseif not exist X:\ (
      net use X: \\test\branchshare$
  exit
  )
  elseif not exist Y:\ (
      net use Y: \\test\branchshare$
  exit
  )
  pause
  </code></pre>