Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

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")

share|improve this answer
add comment

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

share|improve this answer
add comment

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.