I just tried to access a folder like so:
\\somecomputeronmynetwork\somelocation$
When going to this location I'm prompted for a user name and password.
I put one in, and it let me in fine.
Now I need to remove that login, so I can try a different user name and password.
What's the easiest way to do this?
Open a command prompt or from start/run type:
You can also use the following command to list "remembered" connections:
Open your start menu, in the search bar type:
It won't work if your Windows doesn't have login password, so put a password on it
Windows tries to prevent logging on to the same server with different credentials at the same time, for some obscure "security reason".
This interception happens on the client side, not the server side.
You can circumvent this by using the server´s IP Address instead of the Servername. Personally, I do this in the command line:
This way, you can even connect twice to the same share, with different credentials. Incredibly useful when you try to debug user permission problems from the user's computer. Even works to connect to, say c$, on your own computer with admin rights.
You remove a share my either right-clicking it, or
net use x: /delete
But: This does not remove your client's presumed connection to the server. Just browsing to the server in the explorer, without even connecting a share does count, and prevents you from using another credential to log onto that server, unless you disguise the name.
According to Microsoft, this is a feature.
To remove a connection to a PC where it was made to access a folder and the User was cached (ie remains active) must be rigorously used the following procedure (step-by-step):
2 Close all windows explorer of the machine
3 Open the command prompt
4 Execute the command
*** Should be done in this sequence, otherwise can not works. For example, if the command prompt is already open (before the windows explorer) command will not work.
All saved passwords for Windows 7 are saved in Credential Manager.
Control Panel\All Control Panel Items\Credential Manager
If you authenticate with a username and password to a network location, that username and password will remain cached for your logon session. You will need to log off and back on before you can re-authenticate.
I use bogus credentials to really disable access.
that seems to overwrite the old credentials and forces explorer to attempt to use the new bad credentials.
Try this it may work on Windows 7 [it works on XP]. Just type this in the Start->Run-> control keymgr.dll
It'll open up a window where in the stored password & usernames will be stored, you'll be able to delete from there.
You could, of course, remove your connection by doing
But you probably want to re-connect eventually too. Furthermore, if you have cached credentials to the network share, then when you re-establish the connection you may find yourself fighting one of these errors:
or
So instead I suggest fixing the problem without rebooting by doing this:
This has the added bonus that although you will disconnect any existing shares, they won't be forgotten as they would if you had deleted them with something like
net use * /d
.If you don't like command line stuff, you can alternatively restart the Workstation service by going to Services directly:
services
, press EnterThen try your
net use \\somemachine\someshare /user:someuser
command again to get re-prompted for credentials.I have also discovered from @rocketsarefast's answer that Windows will clear the old network credentials when there is a new login attempt.
However, his
net use "\\10.0.0.5\c$" "badpassword" /user:"baduser"
command is way too slow, especially when the client has to wait up to several seconds for the server to respond with a rejection, which is terrible and inconvenient.For my use case, I was able to use the Win32 API to map the network share
\\Server\Share
to theS:\
drive. It disconnects the drive first and then prompts the user with the Windows network login dialog so that the person can logout and login as a different user.Here is the C code
main.c
:Here is the
CMakeLists.txt
:Compile using MinGW-w64 - for 32 and 64 bit Windows:
As an alternative to C, here is an easy C# tutorial on the API:
Mapping a Drive Letter Programmatically:
http://www.blackwasp.co.uk/mapdriveletter.aspx
In Windows 10 (Powershell 5+) you can now also use
Remove-SmbMapping
.Also check out
Get-Command *Smb*
.