0

Im in a somewhat unique situation.

I am trying to create a windows user, using the command line or a batch file. I know how to do that in the basic case:

net user username password /add

The problem is that i am doing this through an endpoint management system, which will log (publicly) whatever command line i am running, so if the password is written in the command line it would be visible to all.

I do have a temporary file that contains a file, so if i could get the net user command to read the password from a file, i could get around this logging issue.

The best I've come up with is:

type password.txt | net user username * /add

Which acts like it works, except that the password is always blank.

Thanks

2
  • Server Fault would actually be a better home for this question; it'll be automatically migrated there once one more vote is cast. But, might I add that you're supposed to create new users with temporary passwords, and require the user to change them the first time they log on. It shouldn't be a security risk that those temporary passwords are visible in plain-text. Commented Apr 1, 2011 at 0:55
  • This is all part of a user management system, in which you are that user, and you are trying to set these passwords on a large batch of computers. Making them go onto the endpoints and change out the temporary password would defeat the purpose in this case. Commented Apr 1, 2011 at 17:46

1 Answer 1

2

Try this:

set /p pwd= <filename.txt
net user username %pwd% /add 
1
  • Thank you! I knew there had to be a reasonable way of doing this. Everyone i talked to wanted me to make a damn vbscript or something. I refuse to live in a world where writing a script was the most reasonable approach to this problem. Commented Apr 1, 2011 at 17:43

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.