• 可以自动输入密码的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

  • 相关阅读:
    用require.js封装原生js轮播图
    最全状态码
    常用DOM结构方法总结
    CSS浮动、绝对、相对定位
    盒模型
    构造函数、原型和实例的关系
    Android测试网络是否连接
    Android第一天
    JQuery图片切换动画效果
    Hibernate增删查改语句
  • 原文地址:https://www.cnblogs.com/itech/p/1784064.html
Copyright © 2020-2023  润新知