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

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

    Simple way I did after trying other answers here

    Method 1: WITHOUT a 3rd party program (I used this)

    1. Create a file called sudo.bat (you can replace sudo with any name you want) with following content powershell.exe -Command "Start-Process cmd \"/k cd /d %cd%\" -Verb RunAs"
    2. Move sudo.bat to a folder in your PATH; if you don't know what that means, just move these files to c:\windows\
    3. Now sudo will work in Run dialog (win+r) or in explorer address bar (this is the best part :))

    Method 2: WITH a 3rd party program

    1. Download NirCmd and unzip it.
    2. Create a file called sudo.bat (you can replace sudo with any name you want) with following content nircmdc elevate cmd /k "cd /d %cd%"
    3. Move nircmdc.exe and sudo.bat to a folder in your PATH; if you don't know what that means, just move these files to c:\windows\
    4. Now sudo will work in Run dialog (win+r) or in explorer address bar (this is the best part :))

提交回复
热议问题