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

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

    For fans of Cygwin:

    cygstart -a runas cmd
    
    0 讨论(0)
  • 2020-12-04 06:41

    I ran into the same problem and the only way I was able to open the CMD as administrator from CMD was doing the following:

    1. Open CMD
    2. Write powershell -Command "Start-Process cmd -Verb RunAs" and press Enter
    3. A pop-up window will appear asking to open a CMD as administrator
    0 讨论(0)
  • 2020-12-04 06:41

    You can use the following syntax, I had the same question and did not think a script should be needed.

    runas /profile /user:domain\username cmd

    This worked for me, it may be different on your network.

    0 讨论(0)
  • 2020-12-04 06:42

    I used runas /user:domainuser@domain cmd which opened an elevated prompt successfully.

    0 讨论(0)
  • 2020-12-04 06:43

    I'm not sure the tool ExecElevated.exe (13KB) will do the job....but it might. Or at least be useful for others with similar needs who came to this page as I did (but I didn't find the solution so I ended up creating the tool myself in .Net).

    It will execute an application with elevated token (in admin mode). But you will get an UAC dialog to confirm! (maybe not if UAC has been disabled, haven't tested it).

    And the account calling the tool must also have admin. rights of course.

    Example of use:

    ExecuteElevated.exe "C:\Utility\regjump.exe HKCU\Software\Classes\.pdf"
    
    0 讨论(0)
  • 2020-12-04 06:43

    Dheeraj Bhaskar's method with Powershell has a missing space in it, alt least for the Windows 10 incarnation of Powershell.

    The command line inside his sudo.bat should be

    powershell.exe -Command "Start-Process cmd \"/k cd /d %cd% \" -Verb RunAs"
    

    Note the extra space after %cd%

    ;)Frode

    0 讨论(0)
提交回复
热议问题