Add Command Prompt As Administrator Context Menu in Windows 10

The command prompt in Windows 10 is the shell environment where you can run text-based console tools and utilities by typing commands. Its UI is very simple and does not have any buttons or graphical commands. In this article, we'll see how to add "Open Command prompt here as Administrator" to the context menu in Windows 10.

Open Command Prompt Here As Administrator File Explorer

Note: Microsoft has removed the command prompt entries from both the Win + X menu and the context menu in Windows 10 Creators Update. See Add Command Prompt back to Win+X Menu in Windows 10 Creators Update and Add Command Prompt to Context Menu in Windows 10 Creators Update to restore this functionality.

You can add the "Open Command prompt here as Administrator" command to the context menu of File Explorer in Windows 10. This will open a new elevated command prompt instance in the current directory that you right clicked on or are browsing with File Explorer.

To add "Open Command prompt here as Administrator" to the context menu in Windows 10, do the following.

Apply the Registry tweak listed below. Paste its contents inside Notepad and save as a *.reg file.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\OpenElevatedCmd]
@="Open command prompt here as administrator"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\shell\OpenElevatedCmd\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k,pushd,%V' -Verb RunAs\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenElevatedCmd]
@="Open command prompt here as administrator"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenElevatedCmd\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k,pushd,%V' -Verb RunAs\""

[HKEY_CLASSES_ROOT\Drive\shell\OpenElevatedCmd]
@="Open command prompt here as administrator"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Drive\shell\OpenElevatedCmd\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k,pushd,%V' -Verb RunAs\""

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenElevatedCmd]
@="Open command prompt here as administrator"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenElevatedCmd\command]
@=

Paste In Notepad

In Notepad, press Ctrl + S or execute the File - Save item from the File menu. This will open the Save dialog. There, type or copy-paste the name "cmd.reg" including quotes.

Save Tweak As Reg File

Double quotes are important to ensure that the file will get the "*.reg" extension and not *.reg.txt. You can save the file to any desired location, for example, you can put it in your Desktop folder.

Double click the file you created, confirm the import operation and you are done.

Import Cmd Tweak

Now right-click any folder.

Open Command Prompt Here As Administrator Open Command Prompt Here As Administrator File Explorer Open Command Prompt Here As Administrator Windows 10

To save your time, I made ready-to-use Registry files. You can download them here:

Download Registry Files

The undo tweak is included.

Alternatively, use you can use Winaero Tweaker.

Tweaker Cmd As Admin Context Menu

You can download Winaero Tweaker here:

Download Winaero Tweaker

9 thoughts on “Add Command Prompt As Administrator Context Menu in Windows 10

  1. Zorro

    Hello,
    you can change

    “Icon”=”cmd.exe”
    by
    “Icon”=”imageres.dll,-5324”

    Reply
    1. Sergey Tkachenko Post author

      Thanks.
      Btw, what is the reason for this change?

      Reply
  2. MDJ

    CMD window opens quite slow but the trick works.

    Reply
  3. SASA

    Using this function seems to affect library functions

    Reply
  4. Kade

    When I use Winaero to “Add Command Prompt as Administrator to Context Menu”, I get the following error when I launch the cmd window: “The system cannot find the drive specified”.

    I think this issue is related to the one reported by Nazar on https://winaero.com/blog/add-command-prompt-to-context-menu-in-windows-10-creators-update/.
    You told him what to change in the .txt file to fix the issue. I can’t seem to change what Winaero uses though.
    Can you apply the changes you told him to WInaero and release an update with those changes?

    Reply
    1. Kade

      Upon further investigation, It seems I get that error only when I am trying to open a cmd file with admin privileges on a folder in a networked drive, such as my H drive.

      Do you know how to fix this?

      Reply
    2. Sergey Tkachenko Post author

      Can you tell me please which Windows version/build has this issue?

      Reply
  5. Charlie

    I used WinAero to add the Open Command Windows in the contect menu, but it doesn’t work anymore, It worked on previous windows 10, and using Previous versions of Winaero.
    Not working on 1909 Windows 10, using the latest Winaero as of today.

    Reply
    1. Sergey Tkachenko Post author

      I will check it out.
      It depends on powershell.
      Do you have it installed?

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *