在包含密码的 Windows 7 上以不同用户身份运行的单行命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12456675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:53:06  来源:igfitidea点击:

Single line command for Run as a different user on Windows 7 that contains a password also

windowscmd

提问by USER_NAME

Is there any single line command for Run As Different User in Windows 7.
I am using following command but then it ask for password

在 Windows 7 中运行不同用户是否有任何单行命令。
我正在使用以下命令,但它要求输入密码

runas /user:USER-NAME "C:\full\path\of\Program.exe"

Is there any way to supply password alsoin above line ? Actually i am launching application from other application so I don't want any user interaction But in above command it ask user for PASSWORD

有没有办法supply password also在上面的行?实际上我是从其他应用程序启动应用程序所以我不想要任何用户交互但是在上面的命令中它要求用户PASSWORD

回答by mnemotronic

PsExec in the MS SysInternals suite:

MS SysInternals 套件中的 PsExec:

psexec -user Administrator -p Passwd "xcopy a.xml \server_over_there\c$\A.xml"

回答by shdobxr

In case the local user is NOT what you need and a specific DOMAIN user is, use:

如果本地用户不是您需要的,而特定的 DOMAIN 用户是,请使用:

/user      Username in form USER@DOMAIN or DOMAIN\USER
           (USER@DOMAIN is not compatible with /netonly)