Unable to supply password to runas from commandline

房东的猫 提交于 2019-11-30 09:54:17

问题


I am unable to supply password to runas from commandline

I have tried the following

cmd /C echo my_admin_password | runas /user:DOMAIN\my_admin_login c:\test.bat

and

echo my_admin_password | runas /user:DOMAIN\my_admin_login c:\test.bat

And the error I get is

Attempting to start c:\test.bat as user "DOMAIN\my_admin_login" ... RUNAS ERROR: Unable to run - c:\test.bat 1326: Logon failure: unknown user name or bad password.

How do I fix this?


回答1:


Take a look at this link: runas utility

It's a runas free utility that have the follwing features:

  1. It accepts password as a command line parameter so that it can be used in batch files.

  2. It can bind started process to the interactive user Desktop so it can be used to start interactive processes from various services such as 24x7 Scheduler, 24x7 Event Server and other.

  3. Note: Professional version of RunAs also supports encryption of the entire command line, which administrators can use to give regular users access to certain programs requiring admin-level privileges. Users don't need to know the administrator's password and cannot use it to run anything else… simple, yet very efficient solution for this common problem.

Also you can try pass the password as input for the process using subprocess.Popen.communicate or even subprocess.Popen.stdin.write.

Other interesting links:

How to pass a password to a process?

Command-line runas with password

PsExec



来源:https://stackoverflow.com/questions/23786511/unable-to-supply-password-to-runas-from-commandline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!