可以自动输入密码的Runas
一 Runas
在使用批處理實現自動化的工程中,我們也許會遇到某些操作必須要在擁有權限的某個用戶下才能執行。但是這時windows自帶的Runas在批處理中調用時不能完成自動輸入密碼。 這時需要使用免費的第三方工具:
1)lsrunas (http://www.moernaut.com/default.aspx?item=lsrunas)
LSrunas can be used to run a command using another user account and passing the password as a parameter
Parameters:
-----------
/user: specifies the username
/password: specifies the password
/domain: specifies the domain
/command: specifies the command to execute and the parameters
/runpath: specifies the path where the command should start
Examples:
---------
lsrunas /user:administrator /password:s3cr3tp@ssw0rd /domain:Mydomain /command:notepad.exe /runpath:c:\
lsrunas /user:administrator /password:s3cr3tp@ssw0rd /domain:Mydomain /command:"C:\Program Files\Internet Explorer\iexplore.exe" /runpath:c:\
lsrunas /user:administrator /password:s3cr3tp@ssw0rd /domain:Mydomain /command:"C:\Program Files\Internet Explorer\iexplore.exe http://www.google.cn" /runpath:c:\
2)sanur (http://www.commandline.co.uk/sanur_unsupported/index.html)
Sanur is a tiny Win32 console utility that 'pipes' a password into the Windows 2000/XP/2003 Runas utility, thereby making Runas scriptable.
Usage
Pipe your normal Runas commandline into Sanur and specify the password on Sanur's commandline or use the /i switch to have Sanur read the password from a file:-
RUNAS <options> | SANUR password
RUNAS <options> | SANUR /i [drive:][path]filename
In otherwords, just add | SANUR password to the end of your working Runas command.
Examples
Pipe the password 'pa55w0rd' into Runas:
runas /u:domain\username program.exe | sanur pa55w0rd
Pipe the password from the file named password.txt into Runas:
runas /u:domain\username program.exe | sanur /i password.txt
Same as above but any Runas errors, such as a logon failure, will be displayed:
runas /u:domain\username program.exe >&2 | sanur /i password.txt
二使用shellrunas來為windows增加右鍵使用不同的用戶來運行程序。
SysinternalsSuite-ShellRunas - Launch programs as a different user via a convenient shell context-menu entry.
完!
作者:iTech
微信公眾號: cicdops
出處:http://itech.cnblogs.com/
github:https://github.com/cicdops/cicdops
總結
以上是生活随笔為你收集整理的可以自动输入密码的Runas的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何设置 homestead zhong
- 下一篇: 怎样让多张图片双面打印按顺序打印?