How do I pass the password to a net use command without being prompted?

2

I need to map a drive without being prompted for the password. I am trying to use net use and putting the password inline within the command. I get an error.

net use H: \\MYSERVER\MYFOLDERS\Backup /user:ABCCompany\JoeUser oasddkjkla

I get the following error: 'sddkj' is not recognized as an internal or external command. If it's not obvious, it's a part of the password that I entered.

The command works fine if I remove the password and enter it upon the dialog box. I'm using Windows 10. Is it still acceptable to pass the password right after the username?

Bill Greer

Posted 2018-05-14T14:44:13.153

Reputation: 123

1The command above looks correct to me. when writing your batch file, what program did you use? – Stese – 2018-05-14T14:54:01.473

As I read the documentation, the password should follow the network share address. – AFH – 2018-05-14T15:34:29.607

@Stese I used both the command window and a SQL Server cmd call. Both returned the same error. – Bill Greer – 2018-05-14T16:13:24.737

@AFH Can you point me to the documentation you read? – Bill Greer – 2018-05-14T16:14:13.863

Type net use /?. or look here.

– AFH – 2018-05-14T17:04:21.050

Answers

4

Please try using:

net use H: \\MYSERVER\MYFOLDERS\Backup oasddkjkla /user:ABCCompany\JoeUser 

David Rossi

Posted 2018-05-14T14:44:13.153

Reputation: 56

0

net use w: \\myserver\fileshare /user:MyID MyPassword

If you have a space in the password you need to put it in quotes, for example:

net use w: \\myserver\fileshare /user:"tom jone" "go to it"

Donavon

Posted 2018-05-14T14:44:13.153

Reputation: 1