如何以管理员身份运行Batch?

时间:2017-09-11 06:58:08

标签: batch-file cmd

我有在Batch / CMD中运行的程序并运行它我首先必须通过管理员打开cmd,然后打开我的程序。有没有办法作为管理批处理程序运行而不在cmd之前打开管理员?

1 个答案:

答案 0 :(得分:0)

你只需要用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