How to complete the RUNAS command in one line [closed]
Sebastian Wright
This Stack Overflow question suggests a command which looks as if it should work, but it doesn't (that answer is deleted now, though):
Single line command for Run as a different user on Window 7 that contains a password also
The command would be:
echo PaSsWoRd | runas /user:Administrator cmdHowever it says:
unknown user name or bad password.
The details are definitely correct though. For example, if I was to run:
runas /user:Administrator...and on the next line, if I typed in PaSsWoRd, it would work no problem.
1 Answer
The runas command does not allow a password on its command line. This is by design (and also the reason you cannot pipe a password to it as input). Raymond Chen says it nicely:
20The RunAs program demands that you type the password manually. Why doesn't it accept a password on the command line?
This was a conscious decision. If it were possible to pass the password on the command line, people would start embedding passwords into batch files and logon scripts, which is laughably insecure.
In other words, the feature is missing to remove the temptation to use the feature insecurely.