batch-filecmdnet-use

Batch file "net use *:" user and password autofill


is possible create batch file, that run command net use s: *some address* and then autofill the username and password?

Something like this:

if exist net use s: /delete
set USER=userid
set PASS=password

net use s: *some address*

Now cmd say "Enter username for some address"

And I need a %USER% variable to be automatically inserted into the username request. Same with password.

Something like this:

if exist net use s: /delete

set USER=userid
set PASS=password

net use s: *some address*

Enter user name for some address:

echo %USER%

Enter password for some address:

echo %PASS%

I know there is a command net use s: *some address* password /USER:user /PERSISTENT:YES But this not working for me. I have error 1312.

The above works, but I dont want writing username and password every time I run this batch file. It is possible?


Solution

  • persistent param is for remembering the drive, for saving credentials use savecred, for example:

    net use x: \\server\bla pwd123 /user:domain\username123 /savecred /p:yes