How to Add a Right-Click Menu Option to Run a Program Elevated

From the Windows Taskbar, you can start a program elevated by holding the Ctrl & Shift keys and then clicking on a pinned shortcut. To launch a program elevated from the right-click menu, you can add custom entries and launch it using a script or using the NirCmd utility. Earlier we wrote about the new elevate command-line argument in NirCmd, which you can implement in the context menu.

This article tells you how to add a right-click menu option to run a program elevated.

Example: Add “Notepad (Administrator)” Option to the Context Menu

  1. Click Start, type regedit.exe and go to:
    HKEY_CLASSES_ROOT\*\shell
  2. Create a subkey named Notepad
  3. Select Notepad, double-click the (default) value and set “Notepad (Administrator)” as the data
  4. Create a string value named HasLUAShield
    (This adds the UAC shield icon to the context menu item. Ref: Add UAC Shield Icon to the Right-Click Menu)
  5. Create a string value named Extended

  6. Under the Notepad key, create another subkey named Command
  7. Select Command, and type in the following value data for (default)
    "C:\Windows\System32\nircmd.exe" elevate notepad.exe "%1"

    (Assuming that you’ve copied NirCmd.exe to the Windows\System32 directory.)

  8. Exit the Registry Editor.

Press and hold the Shift key down, right-click on a file (say, the HOSTS file) that you want to edit using Notepad under elevated privileges, and then click Notepad (Administrator)

Other Possible Uses

Register and Unregister DLLs from the Right-click menu. (REG file)



Open an elevated Command Prompt window from the Desktop context menu. (REG file)

Take Ownership of a file or folder from the context menu. (REG file)

take ownership right-click menu


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

5 thoughts on “How to Add a Right-Click Menu Option to Run a Program Elevated”

  1. My hero! That’s just what I needed.

    Now, Notepad isn’t as good a candidate as Notepad++ is; especially when a Hex Editor plug-in is installed on the Notepad++. Think of the possibilities!

    Reply
  2. You don’t need nircmd, because you can do it natively in Win7. Create a shortcut to your favourite text editor. Edit the properties of the shortcut and under compatibility, click run as administrator.

    Follow the rest of this tutorial but instead of putting nircmd in the registry, put the full path to your shortcut. Works perfectly without installing dodgy third-party software.

    I also found this only to work the way I wanted it to if I didn’t include the “Extended” string value.

    Reply

Leave a Comment