[Solved] NET USE Password Issues

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

[Solved] NET USE Password Issues

#1 Post by alleypuppy » 08 Jun 2011 16:24

Hello all,

I want to create a batch file to automate the process of restoring images using Imagex, but I'm running into a problem.

Normally, what we (my school) would do is type

Code: Select all

net use * \\servername.domain\drive$

and then log in using

Code: Select all

domain\administrator

and type in the password.

What I want to do is create a file that prompts for password input, and then adds that password to the command by using

Code: Select all

net use * \\servername.domain\drive$ /user:administrator %password%

However, the password does not work! Even if I go to Command Prompt and type everything in the correct way, it still does not work. I researched this issue online and couldn't find the answer I'm looking for.

Thanks for any help!
Last edited by alleypuppy on 10 Jun 2011 20:16, edited 1 time in total.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: NET USE Password Issues

#2 Post by Ed Dyreen » 08 Jun 2011 18:19

does the password contains special chars ? like !&|

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: NET USE Password Issues

#3 Post by alleypuppy » 08 Jun 2011 18:51

Ed Dyreen wrote:does the password contains special chars ? like !&|

Just an exclamation mark.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: NET USE Password Issues

#4 Post by Ed Dyreen » 08 Jun 2011 19:12


Are u using delayed expansion ?

Code: Select all

set "User.%%~!.Passw=something^!"

Code: Select all

>nul 2>&1    net use *    /delete /yes
>nul 2>"%%~?" net Use /Persistent:No !Drive.%ServerReferName%! "%%~!" "!User.Administrator.Passw!" /user:Administrator

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: NET USE Password Issues

#5 Post by alleypuppy » 08 Jun 2011 19:42

Ed Dyreen wrote:
Are u using delayed expansion ?

Code: Select all

set "User.%%~!.Passw=something^!"

Code: Select all

>nul 2>&1    net use *    /delete /yes
>nul 2>"%%~?" net Use /Persistent:No !Drive.%ServerReferName%! "%%~!" "!User.Administrator.Passw!" /user:Administrator

I'm not too familiar with DelayedExpansion. In the part that says

Code: Select all

set "User.%%~!.Passw=something^!"

do you want me to specify the password in place of "something"?

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: NET USE Password Issues

#6 Post by orange_batch » 10 Jun 2011 05:45

Try putting quotation marks around %password%. I would help more, but I have no time right now.

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: NET USE Password Issues

#7 Post by alleypuppy » 10 Jun 2011 20:16

I got it. Thanks for the help!

Post Reply