Vista Disconnect From Network Share or UNC Path
Occasionally I’ll try to connect to a UNC share or network device and I’ll forget my proper username and password for the device (NAS, router, another box, etc.). In the case of one of my NAS drives at home, it will let me guess three times what my credentials are, and then it will just connect me as whatever my last guess was, but at that point I’m basically attached as guest. Once that happens, I can see the root of the drive in Windows Explorer, but I can’t get to any of the subfolders due to lack of permissions.
If I try to reconnect, it won’t let me. If I try to map a new network drive, it tells me I can only have one connection open to this device. If I right-click on the IP/sharename in Windows Explorer, there is no option to disconnect. Vista fail.
In order to reconnect (with the correct credentials, once remembered), the only way I’ve found to disconnect without restarting (or at least logging out and back in) is via the command prompt, with the net use command. In this case, if you type net use you might see something like this:
As you can see, I’m connected to a share via its IP address. If you have multiple connections open, you should see all of them listed here. To remove a connection, you simply specify its name and the /Delete flag along with the net use command:
net use \\192.168.0.109\IPC$ /Delete
Following this with simply:
net use
Should show that you no longer are connected to the resource, and you can try once more to attach to it (in Windows explorer, or via net use if you like – what I should do is script these so I don’t have to remember them…).





Comments
Dave said on 27 May 2009 at 6:17 PM
And this still happens in Win7; there's still no reconnect command in net use and explorer doesn't let you reconnect either. Pretty poor IMO.
TT said on 29 May 2009 at 6:45 AM
I sold my NAS device an bought more internal hard drives because of this "feature". Irritating.
MHarr said on 10 Jun 2009 at 9:10 AM
As a consultant that often works at 2-4 offices each week, reestablishing network connections is an issue for me. I solve it by having a vbscript file for each location, and
running it when I get there. I have posted one of my scripts below as an example. Note that under Vista (and Win7), I have to run the script with elevated permissions, but using the excellent Elevation PowerToys from Michael
Murgulo (http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx), I just right-click on the .vbs file and select "Run as Administrator at Command
Prompt".
------------------------------------------
Dim WshShell, oExec
Dim BtnCode
Set WshShell = CreateObject("WScript.Shell")
Do
ExecCmd("net use * /delete /y")
ExecCmd("ipconfig /flushdns ")
ExecCmd("netsh interface ip delete arpcache")
ExecCmd("net use \\cledc1\ipc$ password /user:domain\userid /persistent:no ")
ExecCmd("net use \\clegeacdb2\ipc$ password /user:domain\userid /persistent:no ")
ExecCmd("net use \\cledev01\ipc$ password /user:domain\userid /persistent:no ")
ExecCmd("net use \\cleprint1\ipc$ password /user:domain\userid /persistent:no ")
'ExecCmd("net use p: \\bowcleapps1\apps password /user:domain\userid /persistent:no ")
BtnCode = WshShell.Popup("Do you want to attempt these commands again?", , "Logon Commands:", 4 + 32)
Select Case BtnCode
case 6 'yes
'do nothing, will loop back
case else
Wscript.Quit
End Select
Loop
Sub ExecCmd(sCmd)
Dim oExec, dtStart
Dim input
Wscript.Echo Time & "- " & sCmd
Set oExec = WshShell.Exec(sCmd)
Do While oExec.Status = 0
Do Until oExec.StdOut.AtEndOfStream
input = input & oExec.StdOut.Read(1)
Loop
If Len(Trim(input)) > 0 Then Wscript.Echo Time & "- " & input
input = ""
WScript.Sleep 100
Loop
Do Until oExec.StdOut.AtEndOfStream
input = input & oExec.StdOut.Read(1)
Loop
If Len(Trim(input)) > 0 Then Wscript.Echo Time & "- " & input
input = ""
'WScript.Echo "Status: " & oExec.Status
'WScript.Echo
End Sub
-----------------------------------
Hope this helps.
Jonah said on 08 Aug 2009 at 10:49 AM
Thank you for posting this. I thought I was going insane for not being able to find a way to disconnect through Explorer.
bill said on 03 Sep 2009 at 11:51 AM
Just don't forget your credentials?
Lukas said on 06 Oct 2009 at 5:44 AM
Thanks, this was driving me nuts.
Nick Monroe said on 22 Mar 2010 at 1:34 PM
My powermap script has many cool features. It is the final script on this blog post: nmcit.com/.../visual-basic-lo
-Nick