79

When connecting to a server via Explorer (not a mapped network drive) even if the "Remember my credentials" check box is not selected, Windows remembers the password until you log out. Is there any way to switch user/password for a share without logging out and back in?

11 Answers 11

36

Are you mapping the share to your system, or merely accessing them directly via My Computer? If you map the drive, then you can chose the link to Connect using a different user name and choose the user/password there. The 'net use' command will also allow you to access a share using alternate credentials, but not sure if it will allow you to browse the share without mapping it using those alternate credentials.

6
  • 13
    'net use' worked! The command 'net use \\SERVER * /user:username' works to change the credentials for the share. Thanks!
    – Tim
    Mar 25, 2010 at 3:31
  • 1
    @Tim M: Actually, it seems to work better as net use \\SERVER\SHARE ... -- that is, without the asterisk (and with a sharename, but I assume you used one when you actually ran it ;-). The asterisk causes a drive letter to be assigned; do this too many times and you'll run out!
    – SamB
    Jul 4, 2010 at 20:23
  • I have the same problem, but when doing it I get an error System error 1326 has occurred. and Logon failure: unknown user name or bad password. but I know the username and passwor dare correct
    – Petah
    May 17, 2011 at 3:50
  • 2
    Tried with * "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." Tried with \share, says "The command completed successfully." but I still can't access the share. Feb 14, 2016 at 10:05
  • @tim That solution worked perfectly for me. I had a situation where I renamed my user on Synology NAS to make it align with my Windows user, but the home directory wouldn't show up, even after rebooting both server and client. I removed all old shares, and then executed net use \\SERVER * /user:username. Entered my password successfully and suddenly all my shares popped up. I should add that no drive letters were assigned, contrary to what SamB implies. Precisely the behaviour I expected. =)
    – paddy
    Jul 6, 2016 at 9:04
47

You can override stored credentials for shares in Windows via the Control Panel. I believe this should be possible since around Windows 2000, or at least XP. However, the names of these functions are different in all versions. I am using names from Windows 7 in this post.

  • Open your account page in User Accounts and Family Safety.

    (Click your image in the start menu, or navigate through control panel).

  • In the left hand side panel, select Manage your credentials.

  • Under Windows Credentials:

    • If the server in question has an entry, delete it.

      (Most likely it will not be present, if you haven't been here before).

    • Select Add a Windows Credential.

    • Enter the server (e.g. \\10.0.0.2\myShare).

    • Enter new desired credentials.

Now, when navigating manually to \\10.0.0.2\myShare, it will not use the old credentials any more.

5
  • 3
    Apparently the cmdkey utility is used to manage this from the command line.
    – Martin
    Aug 1, 2014 at 13:35
  • 1
    After adding the new credential, you have to sign out and back in if Windows had already connected the share using a different credential. Aug 17, 2016 at 14:11
  • @EdwardBrey IIRC I did not have to log out. Did you first remove the existing record? Also maybe try disconnecting any mounted network drives for that share.
    – thnee
    Aug 17, 2016 at 14:14
  • Before I added the new credential, I had tried to access the share, which Windows authenticated using the HomeGruop credential, even thought it didn't have access. I didn't get an error, only an empty folder. Since I didn't want to remove the HomeGroup credential, the only way I knew of to tell Windows to stop using it was to sign out. Aug 17, 2016 at 14:26
  • This appears not to immediately expunge the credentials, as I can still log-in to a share through a new Explorer window. I suspect you need to sign out and sign back in to refresh.
    – Jon
    Feb 1, 2021 at 18:13
30

I tried to use what Matrix and Tim both suggested, but that did not work for me. In my case I ended up using

net use \\SERVER\share /delete

What this did was terminate all connections to the share drive and then when I tried to reconnect it prompted me for my username and password again.

2
  • 2
    This worked for me but the connection to the server did not terminate immediatelly, I've been able to browse the shared folder for about a minute before I was kicked out
    – flagg19
    Apr 4, 2015 at 15:37
  • Still works 9 years later Oct 12, 2021 at 14:25
20

To delete cached credentials you can follow the below steps.

You can refer the article http://www.morgantechspace.com/2013/07/how-to-clear-windows-cached-credentials.html

  1. Open Run Window by clicking Start -> Run or click ⊞ Win+R.

  2. In the text box, type the command rundll32.exe keymgr.dll, KRShowKeyMgr and click OK. Note: You can also type and run this command through Command Prompt.

  3. To remove a saved credential you can select one of the entries and select Remove. A confirmation screen will appear. Click on OK and the account will be removed.

  4. You can add additional saved passwords as well by clicking on the Add button and entering the appropriate information.

10

Windows 8 Location is a little different:

Via GUI

Control Panel -> All Control Panel Items -> Credential Manager

-or-

Use the Run Box (Windows Key + R): control /name Microsoft.CredentialManager

9

If you removed or edited the credentials, you are suppose to log out and log back into Windows. Otherwise the cached credentials will still be used.

1
  • 3
    So many answers explain deleting/updating stored credentials via different methods, but none were effective until logging out and in again... at least in my case! Aug 4, 2015 at 22:09
5

WIN + R

cmd -> Enter

net use x: \\192.168.2.10\dir /user:workgroup\xxx yyy /persistent:yes

where xxx is your login,

yyy is password

dir is shared directory

x: - is drive you're mounting to

3

What this did was terminate all connections to the share drive and then when I tried to reconnect it prompted me for my username and password again.

relogin, and check again

2

I just found that you have a list of local user/passwords under:

Control Panel > Credential Manager

(for local network shares, ftp accounts, etc)

1

Access the network share again via name or IP, whichever you haven't already used.

If you connected to \\192.168.2.10\ with the wrong user you can try again once by using the server name instead. If you open \\Server\ you'll be prompted for your credentials again. From then on you'll have two open sessions to the same server but with different users. They seem to last until those logins expire which is potentially until the next logout.

Because of this you need to make sure that you're using the right path from now on! if you needed to login to an account with higher permissions to run a backup, make sure your backup tool now works with \Server[path]` and not the IP.

As far as I know this is the workaround that requires the least amount of effort. It's convenient when you want to avoid the hassle of logging in again or mapping a network drive.

1

Thanks everyone here.I wrote a bat script for this purpose and it succeed every time.Tested on Win10 & Win7.

I restart LanmanWorkstation & lmhosts services and it worked.

set LoginAccount=USERNAME
REM Replace USERNAME by your username

set LoginPasswd=PASSWD
REM Replace PASSWD by your password


set ShareServer=SERVERIP
REM Replace SERVERIP by your server's IP or DNS Name

REM 

REM Check if Credential of target Server Exsit
cmdkey /list:%ShareServer% | findstr /N ^^ | findstr /V "^[1-2]:" | findstr /I /C:" %ShareServer%" >nul

if '%errorlevel%' NEQ '0' (
    REM Non Credential of target Server Exsit
    REM Do nothing
) else (
    REM Credential of target Server Exsit
    REM Delete the Credential
    cmdkey /delete:%ShareServer%
)

REM Add new Credential
REM You can found the new Credential in "Control Panel -> Credential Manager"
cmdkey /add:%ShareServer% /user:%COMPUTERNAME%\%LoginAccount% /pass:%LoginPasswd%

REM Delete All cached Credentials of target Server
net use \\%ShareServer% /delete /Y

REM Set Relative Services Start Type to Auto
sc config LanmanWorkstation start=auto >NUL 2>&1
sc config lmhosts start=auto >NUL 2>&1
sc config netlogon start=auto >NUL 2>&1
sc config sessionenv start=auto >NUL 2>&1
sc config Browser start=auto >NUL 2>&1

REM Restart Relative Services by Powershell
powershell -inputformat none -outputformat none -NonInteractive -Command "Restart-Service LanmanWorkstation,lmhosts -Force"

REM Make new connection
net use \\%ShareServer% "%LoginPasswd%" /user:"%COMPUTERNAME%\%LoginAccount%"

REM Open shared folder on Explorer
explorer \\%ShareServer%

If you are doing this with a domain account, replace %COMPUTERNAME%\%LoginAccount% with %LoginAccount%@YOUR.DOMAIN.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .