title: vbscript Remove mapped drive if the drive letter and path matches
body: <p>Here is the vbscript  that I have which should remove the netwrok drive if it matches the letter and the path but it does not work properly and the array shows 13 mapped drives which I only have 5 on my computer. Doesnt it suppose to check all the available mapped drives on the user's mapped computer?</p>
  
  <pre><code>    Set objShell = CreateObject("Wscript.Shell")
  
  Set objNet = WScript.CreateObject("Wscript.Network") 
  
  Set objExec = objShell.Exec("net use ") 
  strMaps = LCase(objExec.StdOut.ReadAll)
  MapArray=split(strMaps,CHR(10))
  
  for x=1 to ubound(MapArray) 
      if instr(MapArray(x),"W:") AND instr(mapArray(x),"\\path\folder$") then 
          objNet.RemoveNetworkDrive "W:",true,true
      end if
  
      if instr(MapArray(x),"U:") AND instr(mapArray(x),"\\path\folder$") then
              objNet.RemoveNetworkDrive "U:"
      end if  
  
  next
  </code></pre>