use batch file to map network drive that requires username and password

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi


I want to create a batch file that i can schedule to run that maps a network
drive. The thing im not sure on is putting in the username and password as
it will require one.

so if i was to create a network drive like the one below how would i put the
user details into it.

net use z: \\servername\sharename

Thanks

Nick
 
Nick said:
Hi


I want to create a batch file that i can schedule to run that maps a network
drive. The thing im not sure on is putting in the username and password as
it will require one.

so if i was to create a network drive like the one below how would i put the
user details into it.

net use z: \\servername\sharename

Thanks

Nick

When you type net use /? at the Command Prompt then you see this screen:

C:\>net use /?
The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME
NET USE [/PERSISTENT:{YES | NO}]

Your command would therefore have to be something like

net use x: \\YourServer\YourShare /user:Nick SomePassword

Placing passwords into a batch file represents an obvious security risk.
 
Pegasus \(MVP\) said:
Your command would therefore have to be something like
net use x: \\YourServer\YourShare /user:Nick SomePassword

If using this produces the message "System error 1326 has occurred. Logon
failure: unknown user name or bad password" and both the username and
password you've entered are correct, you probably need to specify the
domain name as well:

net use x: \\YourServer\YourShare /user:Domain\Nick SomePassword

Placing passwords into a batch file represents an obvious security risk.

True. The poster will have to evaluate the magnitude of that risk in his
specific situation.
 
Gary Smith said:
If using this produces the message "System error 1326 has occurred. Logon
failure: unknown user name or bad password" and both the username and
password you've entered are correct, you probably need to specify the
domain name as well:

Sometimes you do need to specify the domain, sometimes
you don't. It depends on the setup. The OP should try it
for himself.
 
Back
Top