Off-topic: Windows Update Fix

Some of you may have experienced Windows Update suddenly not working anymore, or an update getting stuck and blocking the entire update process. It is an old Windows problem that has become less common in Windows 11, but it can still happen.

The cause is a corrupted/inconsistent file-based Windows Update database/cache (%windir%\SoftwareDistribution). This can also cause services such as the Windows Update service, BITS, etc. to hang, be unable to be stopped, or fail to start and in some cases it is worser when “svchost.exe” tasks generates high cpu usage, this is also related to this bug.

So I created a script that is able to clear the Windows Update cache under all conditions, even when services hang and can’t be stopped.

Stage 1: The script tries the conventional approach: it attempts to stop the relevant services using a smart method and then clears the Windows Update repository/cache. No reboot is needed.

Stage 2: it only does when “Stage 1” failed, the script uses fallback mechanism: it creates a temporary Script with a scheduled task, then forces a reboot and deletes the Windows Update Cache before the Windows logon screen appears. This allows the cleanup before the affected services have a chance to start.

The idea of cleaning at reboot came to me some time ago, and with the help of Claude Pro and ChatGPT, I was able to optimize and refine the script to make it solid.

In the attached ZIP file is a text file. Unzip it, rename the txt file extension to .cmd or .bat, and run it.

Can the script damage my Windows?
No, I never had issues. It can be run on Windows 11 & 10. Even when you start it on a system that has no Windows Update problems, then also nothing gets damaged. What you need to know is, that after that, it takes a while (usual less than 1h) until Windows Update works again, because Windows does a re-build of the windows update cache.

Fix-Repository_WinUpdate_V0.96.txt.zip (2.3 KB)

2 Likes