title: Impossible to remove a persistent network drive mapping when logged on disconnected
body: <p>Initial situation in Windows 7 (apparently the same in 8.1 and 10):</p>
  
  <ol>
  <li>Create a persistent (!) network drive mapping (a.k.a. "Reconnect at logon").</li>
  <li>Now physically disconnect from the network folder (unplug the cable or shut down the target system)</li>
  <li>Log off and on again. A balloon message will tell "Could not reconnect all network drives", but the drive will still be visible in the Explorer (with a red cross).</li>
  </ol>
  
  <p>At this point I'd like to remove that network drive by code from my application. </p>
  
  <p>For this I'm using WNetCancelConnection2 (which works fine with any other situation), but to make it easier for you to reproduce you can also use the command line.
  Run the command:</p>
  
  <pre><code>net use Z: /delete
  </code></pre>
  
  <p>(or whatever drive letter you've used). It'll tell you that it was completed successfully. Running "net use" will show no network drives connected. HOWEVER, in the Explorer the drive is still there! Rightclicking it now and choosing to disconnect will result in an error. To remove that drive one has to log off and on again or to kill explorer.exe and run it again.</p>
  
  <p>Interestingly, if instead of removing the drive by code or command line you right-click it in the explorer and disconnect it from there it works flawlessly! So that right-click option does something differently than "net use" and the mentioned API call. I'd really like to know <em>what</em> it does.</p>
  
  <p>So what's the problem here? And how to solve it? Any solution in any programming language would be fine. Thanks in advance.</p>