71

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?

Nate
  • 3,378
  • 14
  • 21
Joseph
  • 1,726
  • 3
  • 19
  • 22

11 Answers11

64

Open a command prompt or from start/run type:

net use \\somecomputeronmynetwork\somelocation$ /delete

You can also use the following command to list "remembered" connections:

net use
CodeNaked
  • 103
  • 6
Nate
  • 3,378
  • 14
  • 21
  • 2
    To add a little, you can type just `net use` to see a list of connections, then pick a connection and add the /delete argument like Nate suggested. – Safado Sep 08 '11 at 14:10
  • 2
    Another user suggested ``C:\> net use * /d`` in [ServerFault - Delete all mapped credentials](http://serverfault.com/a/491755/81317) and below. Adding this comment in case readers do not scroll down. – Abraham Mar 05 '15 at 16:10
  • Would like to extend this with also reminding people about quotes around the \\remotepc\path like so "\\remotepc\spaced name" – Angry 84 Mar 11 '15 at 07:28
  • On Win10 `net use * /d` will remove the path from `net use` but Win explorer might still remember the password. Log-off/log-on helps take care of Win explorer. – niCk cAMel Nov 14 '17 at 10:11
  • 1
    like this answer says https://serverfault.com/a/486506/290859 restarting the the "workstation" service is crucial after `net use .../delete` (yes, you could also login/logoff after this command, but for me, restarting "workstationservice" was sufficient.). It's Servicename: LanmanWorkstation // path: C:\WINDOWS\System32\svchost.exe -k NetworkService -p // `sc stop lanmanworkstation` `sc start lanmanworkstationg` (with elevated privileges) – MacMartin Mar 16 '18 at 08:14
  • 1
    Using win7 x64 and a samba file server I have observed the following: After deleting a connection with `net use /delete`, without restarting LanmanWorkstation, it takes a while until `dir \\the\deletedshare` ceases to show the share content. A binary search produced this time is 13 seconds for me. It seems this "waiting period" is extended when the share is accessed again during the time. – Moritz Both Jul 30 '18 at 08:56
  • Yeah this only works for me sometimes. I just tried it and it worked the first time. After that it won't work. My network location will not ask for credentials now. I even did the explorer.exe process restart. Works like 1 out of every 5 times I try. – Ryan Nov 19 '19 at 05:31
52
  1. Open your start menu, in the search bar type:

    manage passwords
    
  2. You will see an application called Manage Windows Credentials.
  3. Open up this application from there you can check/edit/delete your saved network credentials.

It won't work if your Windows doesn't have login password, so put a password on it

chicks
  • 3,639
  • 10
  • 26
  • 36
JamesK
  • 1,646
  • 11
  • 19
7

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:

net use * \\myservername\mysharename /user:mydomain\theotheruser * /persistent:no
==> error - security reasons

net use * \\x.y.z.z'\mysharename /user:mydomain\theotheruser * /persistent:no
==> just fine

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.

Posipiet
  • 1,725
  • 14
  • 13
  • Mapping this way with the password exposes a security vulnerability. Go to Windows Explorer and type a few characters of your shared path, and see if your password appears in plain text. It does on my computer (Win 7 SP1 updated with latest hotfixes as of today. – Lee Grissom Mar 14 '13 at 23:44
  • 1
    Could not reproduce this behavior. I can only speculate you did enter the password in cleartext in the command line order, not when asked. That´s why the second "*" is in the command line - so we get asked, which hides the pw. – Posipiet Apr 24 '13 at 09:14
  • I don't recall exactly, but I'm fairly confident I would never type my password in plaintext. However I'm now using Windows 8 Pro, and I can no longer reproduce. – Lee Grissom Apr 25 '13 at 00:42
6

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):

  1. access the folder with User / Password

2 Close all windows explorer of the machine

3 Open the command prompt

4 Execute the command

Net use * /del

*** 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.

  • 2
    NOTE: "net use \\somecomputeronmynetwork\somelocation$ /d" will remove the credentials for that specific connection. – BrianCooksey Dec 13 '14 at 03:12
5

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.

Lewis
  • 707
  • 4
  • 6
  • See `net use` answers above. And credentials you use through Windows Explorer to access network shares aren't stored in the Credential Manager. – Safado Sep 08 '11 at 14:05
  • I'd be interested in how you explain the following screenshot then. [link](http://iisr2.lewisroberts.com/credman.jpg) – Lewis Sep 08 '11 at 15:01
  • I guess I stand corrected (perhaps). Did you manually add those credentials? I manage 80 users here at my company, all on Windows 7, and everyone connects to multiple shares and as far as I know, not a single person has an entry for it in the Credentials Manager. At any rate, your answer is still misleading. You do not need to log off and log back on to force reauthentication. – Safado Sep 08 '11 at 17:21
  • If you check the `Remember this` checkbox when providing your credentials it will be stored there. However that box is not checked by default. Your answer is misleading though because you do not need to close your login session to re-authenticate. – Nate Sep 09 '11 at 03:12
  • This EXACTLY answers the question "How do I remove login credentials for a network location in win7". All the other answer address changing the network share itself (and consequently the credentials). – anregen Dec 29 '14 at 16:04
5

I use bogus credentials to really disable access.

net use * /d /y
net use "\\10.0.0.5\c$" "badpassword" /user:"baduser"
net use * /d /y

that seems to overwrite the old credentials and forces explorer to attempt to use the new bad credentials.

rocketsarefast
  • 196
  • 2
  • 6
  • Only solution that worked on Windows Server 2016/2019 without having to log out - thank you! Was pretty important in a server setting. – Mike Weir Feb 26 '19 at 19:30
4

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.

Athreya
  • 49
  • 1
  • Thank you, this helped me. I used this to remove then logout login back boom it worked. – Esen Feb 06 '15 at 15:08
2

You could, of course, remove your connection by doing

net use \\somemachine\someshare /d

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:

System error 1272 has occurred.

You can't access this shared folder because your organization's security policies block unauthenticated guest access. These policies help protect your PC from unsafe or malicious devices on the network.

or

System error 1219 has occurred.

Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.

So instead I suggest fixing the problem without rebooting by doing this:

net stop workstation
net start workstation

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:

  • Tap Windows key, type services, press Enter
  • Locate the service named "Workstation". right-click it and choose restart.

Then try your net use \\somemachine\someshare /user:someuser command again to get re-prompted for credentials.

Wyck
  • 130
  • 6
1

Maybe it's specific to Windows 10, but I also needed to do klist purge. So the short answer would be:

net use * /delete
klist purge
mivk
  • 3,457
  • 1
  • 34
  • 29
  • This should be the updated answer for Windows 10 – DanO Apr 12 '21 at 14:25
  • I tried this, but it doesn't work either. I cleared everything in the Credential Manager, deleted the shares (new use /delete), called klist purge and waiting 2 minutes. When I enter "net use Z: \\server_addr\c$", the Z: drive gets connected without asking for a user/password. Any idea? – Simon Aug 01 '22 at 15:28
  • @Simon: Maybe because the share let's you connect without credentials, or because you have the same credentials on that other server than on your local machine? – mivk Aug 01 '22 at 18:53
  • @Mivk: Yes, the local machine uses the same username/password, it may explain, thanks. – Simon Aug 19 '22 at 14:03
1

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 the S:\ 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:

#ifndef UNICODE
#define UNICODE
#endif

#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#define _WIN32_IE 0x0500

#pragma comment(lib, L"mpr.lib")

#include <windows.h>
//#include <stdio.h>

int wmain(const size_t argc, const wchar_t** argv) {
    NETRESOURCE networkResource = {0};
    networkResource.dwType = RESOURCETYPE_DISK;
    networkResource.lpLocalName = L"S:";
    networkResource.lpRemoteName = L"\\\\Server\\Share";
    networkResource.lpProvider = NULL;

    DWORD result = 0;
    result = WNetCancelConnection2(networkResource.lpLocalName, CONNECT_UPDATE_PROFILE, TRUE);
//    wprintf(L"WNetCancelConnection2 result: %d\n", result);

    result = WNetAddConnection2(&networkResource, NULL, NULL, CONNECT_INTERACTIVE | CONNECT_PROMPT);
//    wprintf(L"WNetAddConnection2 result: %d\n", result);

//    getchar();

    return EXIT_SUCCESS;
}

Here is the CMakeLists.txt:

cmake_minimum_required(VERSION 3.7)
project(MapNetworkDrive)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c11 -g3 -pedantic -Wall -Wextra -O0")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS} -municode -mwindows")

set(SOURCE_FILES main.c)
add_executable(MapNetworkDrive ${SOURCE_FILES})
target_link_libraries(MapNetworkDrive mpr.lib)

Compile using MinGW-w64 - for 32 and 64 bit Windows:

As an alternative to C, here is an easy C# tutorial on the API:

XP1
  • 131
  • 2
1

In Windows 10 (Powershell 5+) you can now also use Remove-SmbMapping.

Remove-SmbMapping -RemotePath \\somecomputeronmynetwork\somelocation$

Also check out Get-Command *Smb*.

hansvb
  • 21
  • 1
  • Does not do it for me. I can run this, successfully delete the nameless map (since I never mapped it, but it still sees it just without a letter), and then I can still go directly back to the share via IP address and it STILL has my old credentials. – Ryan Nov 19 '19 at 05:40