How to open an elevated cmd using command line for Windows?

后端 未结 23 1603
既然无缘
既然无缘 2020-12-04 06:21

How do I open a elevated command prompt using command lines on a normal cmd?

For example, I use runas /username:admin cmd but the cmd that was opened do

23条回答
  •  爱一瞬间的悲伤
    2020-12-04 06:47

    My favorite way of doing this is using PsExec.exe from SysInternals, available at http://technet.microsoft.com/en-us/sysinternals/bb897553

    .\psexec.exe -accepteula -h -u "$username" -p "$password" cmd.exe
    

    The "-h" switch is the one doing the magic:

    -h If the target system is Vista or higher, has the process run with the account's elevated token, if available.

提交回复
热议问题