Discussion:
use batch file to map network drive that requires username and password
(too old to reply)
Nick
2005-02-26 12:28:48 UTC
Permalink
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
Pegasus (MVP)
2005-02-26 13:06:17 UTC
Permalink
Post by 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
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:[***@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.
Gary Smith
2005-02-27 04:41:13 UTC
Permalink
Post by Pegasus (MVP)
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
Post by Pegasus (MVP)
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 L. Smith ***@yahoo.com
Columbus, Ohio
Pegasus (MVP)
2005-02-27 05:10:05 UTC
Permalink
Post by Gary Smith
Post by Pegasus (MVP)
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
Sometimes you do need to specify the domain, sometimes
you don't. It depends on the setup. The OP should try it
for himself.

Continue reading on narkive:
Search results for 'use batch file to map network drive that requires username and password' (Questions and Answers)
22
replies
Sucking or Licking....which is tasty?
started 2006-05-20 21:49:19 UTC
family
Loading...