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

Zak Kus
  • 103
  • 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. – Cody Gray - on strike Apr 01 '11 at 00: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. – Zak Kus Apr 01 '11 at 17:46

1 Answers1

2

Try this:

set /p pwd= <filename.txt
net user username %pwd% /add 
nedm
  • 5,630
  • 5
  • 32
  • 52
  • 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. – Zak Kus Apr 01 '11 at 17:43