【问题标题】:How to run Batch as admin? [duplicate]如何以管理员身份运行批处理? [复制]
【发布时间】:2017-09-11 15:15:41
【问题描述】:

我有程序在 Batch/CMD 中运行,要运行它,我首先必须通过管理员打开 cmd,然后打开我的程序。有没有办法在 cmd as admin 之前以管理员身份运行而无需打开批处理程序?

【问题讨论】:

    标签: batch-file cmd


    【解决方案1】:

    你只需要用 runas 运行它:

    runas /user:administrator myscript.cmd
    

    您可能需要使用/savecred 运行它

    显然还有其他可以使用的开关,所以从 cmd 行运行runas /? 将给出可用的开关。

    /noprofile        specifies that the user's profile should not be loaded.
                     This causes the application to load more quickly, but
                     can cause some applications to malfunction.
    /profile          specifies that the user's profile should be loaded.
                     This is the default.
    /env              to use current environment instead of user's.
    /netonly          use if the credentials specified are for remote
                     access only.
    /savecred         to use credentials previously saved by the user.
    /smartcard        use if the credentials are to be supplied from a
                     smartcard.
    /user             <UserName> should be in form USER@DOMAIN or DOMAIN\USER
    /showtrustlevels  displays the trust levels that can be used as arguments
                     to /trustlevel.
    /trustlevel       <Level> should be one of levels enumerated
                     in /showtrustlevels.
    program         command line for EXE.  See below for examples
    

    【讨论】:

      猜你喜欢
      • 2013-01-16
      • 1970-01-01
      • 2017-01-23
      • 2012-10-06
      • 2013-05-29
      • 2013-09-16
      • 2012-07-16
      • 1970-01-01
      • 2015-04-17
      相关资源
      最近更新 更多