Windows – Disconnecting / logging out from Windows network share without restarting Workstation service

network-shareswindowswindows 7

I have a file server running (SMB) that I connected to in Explorer (Windows 7 Professional) by visiting \\1.2.3.4 directly. I logged in as one user, without saving credentials, and now wish to log out (actually I want to change to a different user, but being able to log out in general would be useful).

I have searched around for ways to do this and found a bunch of info that suggests using some form of net use \\1.2.3.4 /del:

However, none of these actually seemed to work for me. I run net use * /del, then use net use to verify that the list is empty, and yet the share mysteriously remains in explorer, unaffected, accessible, and still using the previous login.

Another thing I tried, which also failed, was doing e.g. net use \\1.2.3.4 /user:newusername to switch the credentials. However, even when net use showed an empty connection list, this still produced an error stating that multiple connections to the same resource with different users were not allowed – why there were connections that didn't show up in net use's list is a mystery to me.

I then found this article How to logout from shared folder (microsoft.com), which recommends:

  1. net use * /del (or whatever server).
  2. Clear credentials from Credential Manager.
  3. Restart the Workstation service.

This procedure worked for me. There was nothing of interest in the Credential Manager, as I did not save credentials, however restarting the Workstation service after clearing the connections with net was the key (I did have to close all explorer windows to get the service to restart).

My question is: This is not very convenient at all, especially when I have to explain it to less tech-savvy users. While I could certainly create e.g. a batch script to automate the whole thing, is there an actual, proper, consistent way to do this that doesn't involve restarting services (and possibly doesn't involve the command line, although personally I don't mind)?

Also, a sub-question: It is weird to me that the vast majority of resources I found on this matter didn't suggest restarting Workstation, and the suggested process of using net use alone seemed to work at least for the other people who posted comments on those posts. Is the Workstation restart unique to me and indicative of some other issue on my machine, or was it just left out of all the instructions for some reason? Only the microsoft.com support post had instructions that recommended this step, which is what finally got it working for me.

Logging out of a share seems like it would be a common enough use case to justify some simple way to do it, so I am baffled by how difficult it was for me to figure this out.


Other things I've tried with no effect:

  • Closing all Explorer windows before and after using net use commands (as suggested in Kody Browns's answer), as well as futzing with the "separate process per folder window" settings hoping it was some sort of per-process credential caching (also inspired by that answer).
  • Changing homegroup connection management settings (suggested by holmzi_online's answer at the above microsoft.com post).
  • Killing all explorer processes (including the main one) and restarting explorer after net use * /del (suggested by Robert Greer here, although that issue was with mapped drives).

Best Answer

I got it working by doing the following:

  1. Run net use * /delete
  2. Clear the credentials (e.g. mine is 172.26.190.129, and the date of create is today, just it)
  3. Disable "local connect" (Control Panel\Networking and Internet\Net Connect\Local Connect)
  4. Wait a moment (I don't why but I think it may break some links from my Win7 to Ubuntu and may clear some cache)
  5. Enable "local connect" and it worked..
Related Question