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.
Registering the DLL from an elevated Command Prompt window should work fine:
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:
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.
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.
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.
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.