Frage

I need to build a bat file to run the Runas command.

Here is my command

Runas /user:Administrator "psexec \\\\***.***.***.*** -accepteula -i -u **** -p **** \"C:\\Program Files\\****\\setup.bat\""

When this is ran I am prompt for the password in the command line.

Enter the password for Administrator:

How can I write a bat file that enters the password: password into the prompt?

War es hilfreich?

Lösung

From Why doesn't the RunAs program accept a password on the command line?

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.

In short, your batch program will not be able to do it easily. There are third party utilities that will actually assert themselves to a higher level of authentication and then call your scripts, essentially running them as administrator.

Some cost money, some are free, I don't have enough experience with any of them to tell you either way on their quality.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top