Register and Unregister DLLs Elevated via Right-click Context Menu

This post tells you how to add Register and Unregister commands to the right-click menu for DLL and OCX files in Windows Vista, 7, 8 and 10.

In Windows Vista and higher with User Account Control (UAC) enabled, you require to elevate a task whenever a system-wide operation is to be carried out. Registering system DLLs from a non-elevated state may cause an error. For example, try to register the system module JScript.dll from Start, Search box (i.e. without elevating it). You’re sure to see the error 0x80004005 or 0x80007005 (“ACCESS IS DENIED”) when you do so.

register dll context menu regsvr32

Registering the DLL from an elevated Command Prompt window should work fine:

register dll context menu regsvr32

Method 1: Register DLLs via Context Menu – “runas” verb

To add the Register command in the context menu that’ll run the Regsvr32.exe command under elevated rights, you can use the special runas verb. Here is a REG file that I created, adds the runas verb for DLL and OCX file types in the following registry keys:

HKEY_CLASSES_ROOT\dllfile\runas
HKEY_CLASSES_ROOT\ocxfile\runas

1. Download the file register_runas.reg and save to Desktop.

2. Right-click on the file and choose Merge. Click Yes when you’re asked for confirmation.





You should now see the Register (as Administrator) command in the right-click menu for DLL and OCX file types.

register dll context menu regsvr32

Method 2: Set Regsvr32.exe to always run elevated

As you can use the “runas” verb for only one item, to add a “Unregister” command you need to use a different method than the above. Here is another way to add “Register” and “Unregister” commands to the context menu for DLL files, without using the “runas” verb.

This method instructs the system to always run Regsvr32.exe elevated, by adding a AppCompatFlags\Layers registry entry, and implements the “Register” and “Unregister” context menu entries in the usual way.

REG File

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\System32\\regsvr32.exe"="~ RUNASADMIN"

[HKEY_CLASSES_ROOT\DllFile\Shell\Register]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\DllFile\Shell\Register\command]
@="C:\\Windows\\System32\\regsvr32.exe \"%1\""

[HKEY_CLASSES_ROOT\DllFile\Shell\Unregister]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\DllFile\Shell\Unregister\command]
@="C:\\Windows\\System32\\regsvr32.exe -u \"%1\""

[HKEY_CLASSES_ROOT\OcxFile\Shell\Register]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\OcxFile\Shell\Register\command]
@="C:\\Windows\\System32\\regsvr32.exe \"%1\""

[HKEY_CLASSES_ROOT\OcxFile\Shell\Unregister]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\OcxFile\Shell\Unregister\command]
@="C:\\Windows\\System32\\regsvr32.exe -u \"%1\""

Copy the above lines to Notepad, and save the file with .REG extension. Double-click to run the REG file. This adds the “Register” and “Unregister” commands to the context menu for DLL and OCX files.

register dll context menu regsvr32

That’s it!

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and has a vast experience in the ITeS industry — delivering support for Microsoft's consumer products. He has been a Microsoft MVP [2003 to 2012] who contributes to various Windows support forums.

1 thought on “Register and Unregister DLLs Elevated via Right-click Context Menu

  1. This is great…. but how do I also add the “Unregister (As Admin)” option to the same right click menu?

Comments are closed.