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

link|improve this question
Might do better on superuser.com, as it feels pretty much like an admin task with this description. – sarnold Mar 31 '11 at 23:50
Thanks, seems reasonable. I was in a programming mindset. – Zak Apr 1 '11 at 0:04
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 Apr 1 '11 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. – Zak Apr 1 '11 at 17:46
feedback

migrated from stackoverflow.com Apr 1 '11 at 6:30

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 2 down vote accepted

Try this:

set /p pwd= <filename.txt
net user username %pwd% /add 
link|improve this answer
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 Apr 1 '11 at 17:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.