In a remote desktop connection to a Windows 2008 R2 box I had a drive that showed up a Z: and showed up as Disconnected, but right clicking and selecting “Disconnect” I recieved the error:
The network connection does not exist.
The mapped drive was operational, connected to a network share, but I no longer needed it
Running ProcMon while attempting to remove the drive I noticed an ACCESS DENIED on an .ini file, in a folder I didn’t even have access to at all.
Typically a user’s persistent mapped drives are stored in HKU\Network\<Drive Letter> key within the registry. This drive mapping was persistent across logoff/logon, but kept coming back.
So I thought, what if I add the registry entry in manually, and I set it to a folder I had full control of.
I set the following registry values:
ConnectionType REG_DWROD 0x1
DeferFlags REG_DWORD 0x4
ProviderName REG_SZ Microsoft Windows Network
ProviderType REG_DWORD 0x00020000
RemotePath REG_SZ <file share>
UserName REG_SZ <blank>
After adding this entry, I was able to right click drive and Disconnect worked!