16

I'm running a batch:

"net use j: \\192.168.1.241\sausb /user:srvfeskar\administrator Ratata12 /persistent:yes /p:yes"

After restarting the windows 8 computer. I need to insert the password again.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

2 Answers2

29

If i understand it, you are not running the same command each time after restart. You want to run the command once and then in sucessive logins have the drive mapped without having to validate.

There are two options

  • In net use j: command include the /persistent:yes and /savecred switches, but do not include user or password data. It will be asked and then saved for later use.

  • Use the cmdkey command to store the required credentials in the machine.

    cmdkey /add:191.168.1.241 /user:srvfeskar\administrator /pass:Ratata12

    Then when net use j: \\192.168.1.241\sausb /persistent:yes is used, the credentials stored will be used for the mapping.

MC ND
  • 69,615
  • 8
  • 84
  • 126
  • I did try this, still it asks for username and password ? any suggestions ? – bicepjai Aug 11 '15 at 00:47
  • 2
    This works for me: STEP 1: cmdkey /add:191.168.1.241 /user:srvfeskar\administrator /pass:Ratata12 STEP 2: net use j: \\192.168.1.241\sausb /persistent:yes /savecred – lengxuehx Jun 06 '17 at 12:09
  • Very very weird that I can't simply specify one piece of information (username) from the command line and get prompted for the missing piece of information (password). Also the error message is anything but helpful. – 0xC0000022L Sep 27 '18 at 09:34
  • I'm changing file servers soon, and cmdkey really saves the day here: I can now script how to forget the old credentials and store new ones, and my new persistent share reconnects automatically after a reboot. – Jacob Bruinsma Jan 15 '21 at 18:53
4

/persistent and /savecred are mutually exclusive, and savecred cannot be used with a drive letter, you have to type two commands as follows:

net use j: \\192.168.1.241\sausb /user:srvfeskar\administrator Ratata12 /persistent:yes 
net use \\192.168.1.241\sausb /SAVECRED
  • 1
    This did not save my credentials. After you log out and log back in or restart the system, it cannot reconnect to the network drive. Also, the credentials do not show up in `cmdkey \list`. Tested on Windows 10. – Klaidonis Jan 22 '20 at 14:35
  • 1
    net use \\192.168.1.241\sausb /SAVECRED is not enough to use scheduled task. cmdkey (or manual adding to credential manager) seems the needed procedure. – emoxam Mar 26 '21 at 08:07