title: Determine what drive letter a network share is mapped to using batch file
body: <p>Issue:
  I am having trouble identifying the drive letter that a network share is mapped to using a batch file.</p>
  
  <p>Background:
  We map and use about a dozen network shared drives at work, and the batch file currently maps the drive to the "usual" drive letter. But I want to know if it is mapped to any letter (and if so, what that letter is) because we have over 200 PCs that use these mapped drives, and the letter is often different, so mapping it again to the "usual" letter results in duplicated mapped network drives.</p>
  
  <p>I can see that the network share is mapped to a drive in <code>net use</code>, and it is accessible using both UNC path or the mapped drive letter, so not sure why I can't get the drive letter.</p>
  
  <p>I located the following 3 answers for this issue, but for some reason, none of them are working for me. The URLs, code, and results obtained from each are below. Any help is greatly appreciated!</p>
  
  <hr>
  
  <p><a href="https://stackoverflow.com/questions/3716422/mapping-a-network-drive-without-hardcoding-a-drive-letter-in-a-batch-file">Mapping a network drive without hardcoding a drive letter in a batch file</a></p>
  
  <pre><code>for /f "tokens=2" %%i in ('net use ^| find "\\NetworkShare1\Share1"') do set netdrive=%%i
  </code></pre>
  
  <p>Result: \NetworkShare1\Share1 has been mapped</p>
  
  <hr>
  
  <p><a href="https://stackoverflow.com/questions/35453658/return-users-mapped-drive-letter-from-network-drive-remote">Return users mapped drive letter from network drive remote</a></p>
  
  <pre><code>FOR /F "tokens=2" %%D IN ('net use ^| find ":" ^| find /I "\\NetworkShare1\Share1"') DO ECHO Drive letter is %%D
  </code></pre>
  
  <p>Result: Drive letter is \NetworkShare1\Share1</p>
  
  <hr>
  
  <p><a href="https://stackoverflow.com/questions/19555441/how-to-get-drive-letter-of-mapped-network-drive">How to get drive letter of mapped network drive</a></p>
  
  <pre><code>for /f "tokens=2,3" %%i in ('net use') do if '%%j=='\\NetworkShare1\Share1 set drive=%%i
  echo %drive%
  </code></pre>
  
  <p>Result: Echo is off.</p>