Adding “Run as Administrator” to a Registration File Context Menu

If you are trying to merge a registration file in Windows Vista that has non-HKEY_CURRENT_USERS entries from a Standard User Account then the merge will probably fail because the registration file wants to write to system wide registry settings such as HKEY_LOCAL_MACHINE and HKEY_CLASSES_ROOT, for example. The only way I know of to accomplish the merge is to open an Elevated Command Prompt and then merge the registration file. But I grew tried of this very quickly so I modified the registry to add a "Run as administrator" to the Registration file (*.reg) context menu.

NOTE

To enlarge the images, simply click on the images you would like to view. With Internet Explorer 7, you can right-click on the image to select Open in New Tab.

    

CAUTION

Editing the Windows Vista registry can cause serious issues such as system instability when editing/deleting the wrong entries. Please use the Registry Editor with extreme caution.

CAUTION

Before making any changes to the Windows Vista Registry, please backup your Windows Vista Registry by creating a System Restore point using the direction from "Create a System Restore Point".

To Add "Run as administrator" to Registration File Context Menu – Manual Method

NOTE

To enlarge the images, simply click on the images you would like to view. With Internet Explorer 7, you can right-click on the image to select Open in New Tab.

  1. Open the Registry Editor with Elevated Privileges, refer to "Opening the Registry Editor with Elevated Privileges" blog article for instructions.
  2. Navigate to:

    HKCR\regfile\shell

  3. Create a new key by right-clicking "shell" to select New > Key. Name the new key RunAs.
  4. Create a new key by right-clicking "RunAs" to select New > Key. Name the new key command.
  5. Double-click (default)located at:

    HKCR\regfile\shell\RunAs\command

  6. Enter the following in the Value Data field:

    regedit.exe "%1"

    [HKCR\regfile\shell\RunAs\command]
    Name: (default)
    Type: REG_SZ
    Data: regedit "%1"

To Add "Run as administrator" to Registration File Context Menu – Using Reg Add

  1. Open a command prompt with Elevated Privileges, refer to "Opening an Elevated Command Prompt" blog article for instructions.
  2. Type the following in the elevated command prompt window:

    reg add HKCR\regfile\shell\RunAs\command /ve /d "regedit.exe \"%1\""

To Add "Run as administrator" to Registration File Context Menu – Using a Registration File

NOTE

To enlarge the images, simply click on the images you would like to view. With Internet Explorer 7, you can right-click on the image to select Open in New Tab.

  1. Download RunAs.REGFILE.reg to a folder on your hard drive.
  2. Open a command prompt with Elevated Privileges, refer to "Opening an Elevated Command Prompt" blog article for instructions.
  3. Change directories to the folder where you saved RunAs.REGFILE.reg. For example, if you saved the RunAs.REGFILE.reg file to "c:\users\Bill", then type the following in the elevated command prompt window:

    cd "c:\users\Bill"

  4. Then type the following in the elevated command prompt window to merge the registration file into the registry:

    RunAs.REGFILE.reg

  5. Click Yes to confirm you want to merge the RunAs.REGFILE.reg file into the registry.
  6. A confirmation window will appear asking if you want to merge the RunAs.REGFILE.reg registration file into the Windows Vista registry. Click Yes to continue with the merge of the registration file. Refer to Image below.

     

  7. If you are successful with merge of the RunAs.REGFILE.reg registration file then the following window should appear. Refer to Image below.

NOTES

The RunAs.REGFILE.reg file is from my web server (http://lprf.homeserver.com).  You also can view the contents of the RunAs.REGFILE.reg file by right-clicking the file and selecting Edit. You may need to log off then log on to your user account or restart your computer for the changes to take affect.

NOTE

To enlarge the images, simply click on the images you would like to view. With Internet Explorer 7, you can right-click on the image to select Open in New Tab.

Platforms Tested

  • Microsoft Windows Vista, x86 versions

Version 1.3
Edited: May 3, 2012

3 Responses to Adding “Run as Administrator” to a Registration File Context Menu

  1. Pingback: Adding an Elevated “Command Prompt Here” for Folders and Drives Context Menu « BillJr's Space

  2. Pingback: Internet Explorer 7 Slow to Respond after Applying Security Update in Windows Vista « BillJr's Space

  3. Thanks for this! Really helpful.
    Unfortunately for me, I need to embed the administrator’s login info so that anytime my limited user run the reg script it won’t ask for the admin password.

    Hope to hear from you.
    Thanks!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.