Open Command Prompt with Administrator Privileges Anywhere

You can open a new Command Prompt window directly to a folder location by right-clicking the folder in Windows while holding the Shift key and then selecting Open Command Window Here. But this opens it to user-level privileges. However, you can add a shortcut to the right-click context menu that opens it with administrator privileges.

Open Notepad, insert the following text, and save as AddToOpenAsAdmin.reg:

Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\shell\runas]
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Open Command Window Here as Administrator"
"Icon"="C:\\Windows\\System32\\imageres.dll,-78"
[-HKEY_CLASSES_ROOT\Directory\shell\runas\command]
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

Then to apply, execute the AddToOpenAsAdmin.reg file. Now you’ll see an admin option when right-clicking a folder while holding down Shift.

About The Author

7 thoughts on “Open Command Prompt with Administrator Privileges Anywhere”

  1. I have found a work around:

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHereAsAdmin]
    @=”Open command window here as administrator”
    “Extended”=-
    “Icon”=”imageres.dll,-5324″

    [HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHereAsAdmin\command]
    @=”PowerShell -windowstyle hidden -Command \”Start-Process cmd -ArgumentList ‘/s,/k,pushd,%V’ -Verb RunAs\””

    [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAsAdmin]
    @=”Open command window here as administrator”
    “Extended”=-
    “Icon”=”imageres.dll,-5324″

    [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAsAdmin\command]
    @=”PowerShell -windowstyle hidden -Command \”Start-Process cmd -ArgumentList ‘/s,/k,pushd,%V’ -Verb RunAs\””

    [HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHereAsAdmin]
    @=”Open command window here as administrator”
    “Extended”=-
    “Icon”=”imageres.dll,-5324″

    [HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHereAsAdmin\command]
    @=”PowerShell -windowstyle hidden -Command \”Start-Process cmd -ArgumentList ‘/s,/k,pushd,%V’ -Verb RunAs\””

    [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHereAsAdmin]
    @=”Open command window here as administrator”
    “Extended”=-
    “Icon”=”imageres.dll,-5324″

    [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHereAsAdmin\command]
    @=”PowerShell -windowstyle hidden -Command \”Start-Process cmd -ArgumentList ‘/s,/k,pushd,%V’ -Verb RunAs\””

    Hope it helps someone!

    1. It made things more convenient, so thanks!

      I did make a change because the name is a bit cumbersome.

      All instances of:
      “Open command window here as administrator”
      changed to:
      “Open command window here (Admin)”

      It is a minor cosmetic change, so others need not follow suite.

    1. Windows Registry Editor Version 5.00

      [-HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHereAsAdmin]
      [-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAsAdmin]
      [-HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHereAsAdmin]
      [-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHereAsAdmin]

Leave a Comment

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top