I first addressed this issue in tip 5920 ยป How do I speed up Disk Cleanup or possibly prevent it from hanging?

Another cause of this problem can be that Disk Cleanup starts compressing files in the system cache, and some of these files are being used during the compression.

To prevent this behavior:

1. Copy / Paste the following to a CompressOldFiles.reg file:

REGEDIT4

\[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\\{B50F5260-0C21-11D2-AB56-00A0C9082678\}\]


2. Merge the CompressOldFiles.reg file with your registry, or run regedit /s CompressOldFiles.reg.