Disk Cleanup Crashes on Windows 10/11: The .log File Bug
Disk Cleanup crashes when scanning Recycle Bin or temp files. It's a corrupted .log file in the WinSxS folder. Delete it, not the whole folder.
When This Happens
You open Disk Cleanup (cleanmgr.exe), select files to delete—usually Recycle Bin or Temporary files—and click OK. The progress bar appears, then freezes at some percentage. After a minute or two, the window vanishes without warning. No error dialog. The cleanup never finishes. You might see an event log entry with Application Error from cleanmgr.exe, but nothing more specific.
This is especially common after a Windows Update rollup or a feature update like 22H2 or 23H2. The trigger is often the Windows Update Cleanup or Delivery Optimization Files category—Disk Cleanup tries to enumerate a deeply nested folder with a corrupted log file, and it chokes.
Root Cause
What's actually happening here is that Disk Cleanup calls the Windows Component Servicing APIs to scan files in C:\Windows\WinSxS. That folder holds internal system components, and it's full of .log files that track file operations during updates. If any single .log file gets corrupted—truncated, filled with null bytes, or with a malformed header—the API call that reads it throws an unhandled exception. The UI thread doesn't catch it properly, so the process just dies.
The corruption usually comes from a failed update installation or a disk write error during a previous update. SFC (System File Checker) won't fix this because it only checks system files against the component store, not temporary log files inside WinSxS. DISM might help, but often it can't repair a file that's technically not a system file—it's a log artifact that got corrupted during creation.
Fix: Step by Step
Skip the Disk Cleanup for now. We're going after the corrupted file directly. You'll need administrative rights.
- Open an elevated Command Prompt. Press Win + X, select Terminal (Admin) or Command Prompt (Admin).
- Navigate to the WinSxS folder. Run:
cd C:\Windows\WinSxS - Identify corrupted .log files. Run this PowerShell command (yes, from cmd or PowerShell admin terminal):
This lists all .log files with zero bytes—those are the usual suspects. If that returns nothing, look for files with a size under 10 bytes:Get-ChildItem -Path . -Filter *.log -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Length -eq 0 } | Select-Object FullName
The corrupted files are often in subdirectories likeGet-ChildItem -Path . -Filter *.log -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Length -le 10 -and $_.Length -gt 0 } | Select-Object FullNamewow64_microsoft-windows-...oramd64_microsoft-windows-.... - Back up the corrupted files. Before deleting, copy them somewhere safe:
Replace the path with what you found. If there are many, use a loop in PowerShell.mkdir C:\LogBackup copy "C:\Windows\WinSxS\path\to\corrupted.log" C:\LogBackup\ - Delete the corrupted .log files. From the elevated prompt, delete each one:
If you have many, you can do them all with:del "C:\Windows\WinSxS\path\to\corrupted.log"
Warning: Only delete zero-byte or very small (under 10 bytes) .log files. Deleting a normal .log file won't break Windows, but it's unnecessary.Get-ChildItem -Path C:\Windows\WinSxS -Filter *.log -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Length -eq 0 } | Remove-Item -Force - Try Disk Cleanup again. Press Win + R, type
cleanmgr.exe, run it normally. It should now scan and complete without crashing.
If It Still Fails
If Disk Cleanup still crashes after removing zero-byte logs, the corruption might be deeper—a .log file with a valid size but broken content. Here's a more aggressive approach:
- Run DISM and SFC in order. Even though I said they often don't fix this, try them anyway:
Then reboot.DISM /Online /Cleanup-Image /RestoreHealth sfc /scannow - Use the Storage Sense alternative. Go to Settings > System > Storage > Storage Sense. Turn it on, or click Run Storage Sense now. It uses the same underlying APIs but sometimes handles errors more gracefully than the classic Disk Cleanup UI.
- Delete the entire SoftwareDistribution folder. This is a nuclear option, but it works when WinSxS log corruption is part of a larger update mess. Stop the Windows Update service, rename the folder, restart the service:
Then run Disk Cleanup again. Windows Update will rebuild the folder on the next scan.net stop wuauserv net stop bits ren C:\Windows\SoftwareDistribution SoftwareDistribution.old net start bits net start wuauserv - Last resort: Reset Windows Update components. Use the official Microsoft script from their support site, or manually run the PowerShell cmdlets from their troubleshooting guide. I've seen this fix Disk Cleanup crashes that persisted through everything else.
One more thing: if you're on an SSD, and Disk Cleanup still crashes, check your drive health with wmic diskdrive get status. A failing drive can cause read errors that mimic log corruption. But 9 times out of 10, it's that single zero-byte .log file hiding in WinSxS.
Was this solution helpful?