How to save the password for a mapped network drive?

14

7

I have a map drive created from Tools > Map network drive.

The drive is mapped to a different machine's shared folder. So each time I switch off the machine, it asks for the password when I open the drive.

Is there a way to save this password?

Ravisha

Posted 2010-04-13T04:56:22.940

Reputation: 325

Answers

18

Map the drive using this syntax at the command prompt:

net use X: \\Hostname\Share /savecred /p:yes

It will then prompt for a username and password, which will be saved and will not prompt even after a reboot.

You can also add the credentials by opening Start → Run → control userpasswords2 → Advanced → Manage Passwords.

This feature exists on Windows XP and later.

Stephen Jennings

Posted 2010-04-13T04:56:22.940

Reputation: 21 788

I initially messed up the credentials I stored with /savecred (used domain instead of machine name). To open a small GUI for adding/deleting passwords, run rundll32.exe keymgr.dll, KRShowKeyMgr from a command line. cmdkey is also available. See this thread.

– Mark Berry – 2014-07-16T23:28:20.377

Its Not working – Ravisha – 2010-04-15T05:04:21.573

@Ravisha What happens when you try? Do you get an error message? Can you post the exact text you are typing which isn't working? – Stephen Jennings – 2010-04-15T05:32:44.730

I have given the proper password in the way you mentioned.I am not getting any error,but its asking for password when i open the mapped drive – Ravisha – 2010-04-15T06:11:43.777

If you go to control userpasswords2 > Advanced > Manage Passwords, does the computer name show up there? Try deleting it if so, then run the net use command again, and make sure you get the message "The operation completed successfully." – Stephen Jennings – 2010-04-15T13:58:07.173

did that,but still on restart the password has to be entered – Ravisha – 2010-06-01T02:47:26.023

this does not work! – user65130 – 2012-05-22T12:27:15.127

I am not sure, but this Microsoft support article seems to state /savedcred may only be for XP: http://support.microsoft.com/kb/287536

– Sun – 2014-06-13T18:20:30.417

2

Stephen Jennings has the correct answer but I have found that there are quite a few XP computers that still do not save the password to the network drive after a reboot (as Ravisha and user65130 may have found out). The only solution I have found on those XP computers is to put this in a batch file:

net use X: \\Hostname\Share password /savecred /p:yes

or

net use X: \\Hostname\Share /user:machinename\username password /savecred /p:yes

Put the batch file in the Startup folder and then on every reboot the mapped drive is reconnected. The bad thing about this method is that the password is being saved as plaintext in a file.

Jeff Baker

Posted 2010-04-13T04:56:22.940

Reputation: 141

1I believe the whether XP saves the password or not should depend on the edition (Home / Media Center vs Professional), but I have encountered all sorts of weirdness with saving credentials for network shares across Windows editions (and versions). – lzam – 2014-09-21T01:08:23.157

1

First, if you're in a domain environment, you would give the correct NTFS permissions to the share and setup a login script. I like using net use

net use z: \\server\sharename

If you're in a workground environment, if you create the same user name and password on the shared machine as you're logging in at the client you can do the same thing.

If something like that isn't available you can specify the user name and password with the script.

net use z: \\server\sharename /user:machinename\username Password

I make it a little harder for the average user to know the permissions and set it as an exe with this tool.

http://download.cnet.com/Bat-To-Exe-Converter/3000-2069_4-10555897.html

Nixphoe

Posted 2010-04-13T04:56:22.940

Reputation: 566

Using the second method, if the drive becomes disconnected (not unmapped, just disconnected), it will prompt for a password next time it is accessed. The /savecred argument stores the credentials in LSASS protected storage so they can be reused automatically. – Stephen Jennings – 2010-04-13T05:40:45.953

1

@echo off
echo --------------------------delete map drive all------------------------
net use * /delete /yes
echo ------------------create drive --------------------------------
net use m: \172.16.0.136\Source /user:aleg\masr masr2006*
net use n: \172.16.0.136\scanner_bat_test /user:alwq\4288044 masr2006*    
echo ---------------------------------------------------    
EXIT

orestes

Posted 2010-04-13T04:56:22.940

Reputation: 19

0

@echo off
echo --------------------------delete map drive all------------------------
net use * /delete /yes
echo ------------------create drive --------------------------------
net use m: \\172.16.0.136\Source /user:aleg\masr masr2006*
net use n: \\172.16.0.136\scanner_bat_test /user:alwq\4288044 masr2006*
echo ---------------------------------------------------

EXIT

masrnet2006

Posted 2010-04-13T04:56:22.940

Reputation: 9

6You should try to explain what you are doing, just copying and pasting a script with your settings is not really useful. – Matteo – 2012-12-16T11:49:57.987

1He is deleting all the drive mappings, then remapping m: and n: using domain credentials and password. I think it is not well written script since if you have other drive mappings besides m: and n: they will be blown away by the first part of the script. – Sun – 2014-06-13T18:22:10.983