Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to complete the RUNAS command in one line [closed]

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 cmd 

However 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.

like image 577
Accendi Avatar asked Apr 19 '13 14:04

Accendi


People also ask

How do you execute a Runa command?

To use runas at the command line, open a command prompt, type runas with the appropriate parameters, and then press ENTER. In the user interface for Windows Vista, the Run as… command has been changed to Run as administrator.

How do I close a command line?

To close or exit the Windows command line window, also referred to as command or cmd mode or DOS mode, type exit and press Enter . The exit command can also be placed in a batch file.

Can I pass the password to the runas command?

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

What is the runas command for administrator?

The Runas command enables a user to perform tasks such as running a specific program with different permissions than what is currently available. Admins commonly use it to quickly perform administrative tasks while logged in to a non-admin account.


1 Answers

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:

The 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.

like image 90
Bill_Stewart Avatar answered Oct 20 '22 00:10

Bill_Stewart