Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

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

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

    
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

1 Answer 1

up vote 2 down vote accepted

Try this:

set /p pwd= <filename.txt
net user username %pwd% /add 
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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