I'm 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
feedback

2 Answers

up vote 2 down vote accepted

Someone pointed me to Server Fault, which provided me with the correct answer:

set /p pwd= <filename.txt
net user username %pwd% /add 

(Courtesy of server fault user "nedm")

link|improve this answer
feedback

You could use this PowerShell script to create the accounts from a CSV file containing the usernames and passwords.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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