When trying to empty the recycle bin in Microsoft Windows Vista/7/2008/2008 R2 (and probably XP, though it was not tested) via the "Empty the Recycle Bin" option, the following error appears:


I've had this problem in my Windows computer for a few months already but only now I decided to check what it was all about.

For some reason, an important registry key disappeared from my operating system (which isn't statistically weird given that my Windows installation is already 28 months old).

First, I made some research about this problem but it ended up non-conclusive and without solutions nor interesting workarounds.

As such, I will show you how I managed to fix this issue:


1.
I started searching for relevant entries about the recycle bin with the Registry Editor (regedit).

[You can run the Registry Editor by writing "regedit" in the start menu, then right-click the first result that appears and selecting "Run as administrator".]

I stumbled upon the following suspicious key:

HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\empty\command

2.
I went to another computer I had working alright and searched for the same key to find out that the contents were different.

HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\empty\command

3.
I just tried to copy the DelegateExecute String key to my bad Windows installation registry.

However, I had no permissions to write in the original key because it's not supposed to be touched.

When trying to add the missing key, permission was denied 

4.
I used the amazing RegDACL program from Frank Heyne to unlock the key:

In a Windows Command Prompt (or PowerShell) execute the following command (having RegDACL in either the path or the current directory):

[You can run the Command Prompt by writing "cmd" in the start menu, then right-click the first result that appears and selecting "Run as administrator".]

RegDACL.exe HKCR\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\empty\command /GGA:W(NI)

Now it should be possible to change the registry key (if you do it as Administrator):

C:\>RegDACL.exe HKCR\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\empty\command /GGA:F(CI)



RegDACL 6.2 - Permissions Manager for Registry keys for Windows

Copyright (c) 1999-2007 Frank Heyne Software (http://www.heysoft.de)

This program is Freeware, use it on your own risk!





Granting "W(NI)" access for predefined group "Administrators"

 - adding new entry

Don't forget to restore the original permissions afterwards.

5.
Finally I just added a String key named: DelegateExecute with the content: {48527bb3-e8de-450b-8910-8c4099cb8624}, or use the .reg inside the previous key (HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\empty\command) file I provide at the end of this post.

It should look like this after adding the missing key


The problem should now be fixed, if you go to the "Empty the Recycle Bin" option you'll see the familiar dialog:



One more thing. I had a backup key in my computer made by the trial TuneUp Utilities 2012, so it may have been the cause of this issue.

Update of 2012-04-19:

Download the .reg file that fixes the key automatically: DelegateExecute.reg
(you still need to apply the permissions explained earlier)

Useful links:
RegDACL