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