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

后端 未结 23 1584
既然无缘
既然无缘 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:45

    The following as a batch file will open an elevated command prompt with the path set to the same directory as the one from where the batch file was invoked

    set OLDDIR=%CD%
    powershell -Command "Start-Process cmd -ArgumentList '/K cd %OLDDIR%' -Verb RunAs "
    

提交回复
热议问题