runas /profile /user:administrator "cmd /c net user /add [username] [password]".

I used the above command to create a new user using administrator permissions. After I enter this command, it prompts me for the administrator's password and when I input the password it creates the new user.

But I don't want to manually sit and type in the password. Is it possible to automatically pass in the password when prompted?

I tried the following command, but it gives me an error.

echo abcd | runas /profile /user:administrator "cmd /c net user /add [username] here, abcd is the administrators password.

the error I get is:

C:\Users\pjs>echo abcd | runas /profile /user:administrator "cmd /c net user /add joe hello"

Enter the password for administrator:

Attempting to start cmd /c net user /add joe hello as user "administrator" ...

RUNAS ERROR: Unable to run - cmd /c net user /add joe hello 1326: The user name or password is incorrect.

Is there any other way to solve this.

1 Answer 1


You could use one of the runas switches as long as the password doesn't change:

runas /user:administrator /savecred "cmd /c..."

The first time you run this it'll ask you for the password, subsequent times it'll not prompt you for the password as long as you specify the savecred switch and as long as the password doesn't change.

  • Can it not pass the password every time. Like save the password in a file and when it prompts for a password it should read the file.. Something of that sort. I have no idea about the syntax which could be used.
    – pjs
    Mar 19, 2015 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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