Getting username to pass to Net user command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
phil_jones
Posts: 2
Joined: 08 May 2013 04:24

Getting username to pass to Net user command

#1 Post by phil_jones » 08 May 2013 04:30

Hi
I'm trying to do a batch file to ask for input of a username then pass that input to the Net user command to find out info.
At the moment its coming back with all users on the domain rather than the input of the username. Any ideas, people?

Thanks

Phil


@Echo Off


set /P INPUT=uname:


net user /domain %uname%

pause

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Getting username to pass to Net user command

#2 Post by foxidrive » 08 May 2013 05:09

Any good?

Code: Select all

net user /domain %input%

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Getting username to pass to Net user command

#3 Post by Squashman » 08 May 2013 05:50

You are definitely confusing your variable name with your prompt string.
Read the help for the SET command. The variable name is always to the left of the = symbol.

phil_jones
Posts: 2
Joined: 08 May 2013 04:24

Re: Getting username to pass to Net user command

#4 Post by phil_jones » 08 May 2013 08:44

Squashman wrote:You are definitely confusing your variable name with your prompt string.
Read the help for the SET command. The variable name is always to the left of the = symbol.


It's just possible I may kiss you. Or buy you a beer. All working thank you

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Getting username to pass to Net user command

#5 Post by Squashman » 08 May 2013 09:59

phil_jones wrote:
Squashman wrote:You are definitely confusing your variable name with your prompt string.
Read the help for the SET command. The variable name is always to the left of the = symbol.


It's just possible I may kiss you. Or buy you a beer. All working thank you

Not me but maybe Foxidrive. Not sure if they do that down under. :lol:

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Getting username to pass to Net user command

#6 Post by foxidrive » 08 May 2013 21:16

Yes, we drink beer here. :D

Post Reply