Windows Update Stuck or Failing? Fix Windows Update with a Free PowerShell Script

Windows Update stuck or failing? This free PowerShell script safely resets the update components so you can fix Windows Update without reinstalling Windows. Below you’ll find step-by-step instructions, the full script, manual commands, and fixes for common error codes.

Windows Update stuck or failing? Fix Windows Update using a free PowerShell script on Windows 11.
Fix Windows Update with Free Powershell script


Explore more: Guides and Tutorials

Windows Update stuck again?

You click Check for updates and nothing happens. Or the progress bar sits at 0% for hours. Or you get an error code such as 0x80070002 and no explanation.

This is one of the most common Windows problems, and it is usually fixable without reinstalling Windows. In most cases the update cache is corrupted or an update service has stopped. Resetting those components gives Windows Update a clean start.

This guide gives you a free PowerShell script that does the reset safely, explains every step it takes, and shows you the manual commands if you prefer to do it yourself.

Why Windows Update gets stuck

Windows downloads updates into a cache folder called SoftwareDistribution and keeps signature data in a folder called catroot2. If a download is interrupted, the disk fills up, or a system file is damaged, these folders can end up in a bad state. The update services then keep retrying the same broken download.

Common causes:

  • A corrupted update cache (SoftwareDistribution or catroot2)
  • A required service (Windows Update, BITS, Cryptographic Services) stopped or disabled
  • Low free disk space (updates often need 10 GB or more)
  • A pending restart that was never completed
  • Damaged Windows system files
  • Proxy, VPN or policy settings blocking the update servers

Signs you need to reset Windows Update

  • “Checking for updates” never finishes
  • Downloads stay at 0% or a fixed percentage
  • The same update fails again and again
  • Error codes such as 0x80070002, 0x80070422, 0x80073712 or 0x8024402C
  • The Windows Update page is blank or the “Check for updates” button does nothing

What this script does

The script is called Repair-WindowsUpdate. It works in two stages.

Stage 1: checks only (changes nothing). It reports:

  • Whether a restart is pending
  • How much free space your system drive has
  • The state of the update services
  • Whether update policies (work, school or tweak tools) override Windows Update
  • The most recent Windows Update errors from the event log

Stage 2: repair (only when you add -Execute). It then:

  1. Sets any disabled update service back to Manual
  2. Stops the update services
  3. Clears stuck BITS download jobs
  4. Renames the SoftwareDistribution and catroot2 folders so Windows rebuilds them (nothing is deleted; the old copies are kept as .bak folders)
  5. Restarts the services
  6. Starts a fresh update scan
  7. Optionally runs DISM and SFC to repair damaged system files (-DeepRepair)

Because the old folders are renamed rather than deleted, you can undo the change if something unexpected happens.

Before you start

  • Save your work and plug in your laptop. The repair itself takes a minute or two, and the optional deep repair can take 15 to 40 minutes.
  • You need an Administrator PowerShell window.
  • Your update history list will look empty afterwards. Installed updates stay installed.
  • The script is provided as is, without warranty. Always run the check-only mode first.

How to use the script to fix windows update

Step 1. Open PowerShell as Administrator. Right-click the Start button and choose Terminal (Admin) or Windows PowerShell (Admin).

Step 2. Paste the script. Copy the full script from the section below and paste it into the window, then press Enter. Nothing runs yet. It only loads the Repair-WindowsUpdate command.

Step 3. Run the check first.

Repair-WindowsUpdate

Read the output. It lists problems such as a pending restart, low disk space or disabled services, and shows the latest update error codes.

Step 4. Apply the repair.

Repair-WindowsUpdate -Execute

Step 5. If it still fails, run the deep repair.

Repair-WindowsUpdate -Execute -DeepRepair

Step 6. Restart your PC, then open Settings > Windows Update > Check for updates.

The script to fix Windows Update

Copy the whole block, including the last line.

How the script works, command by command

You can read the code above, but here is what the main parts do.

Service reset. Windows Update depends on four services: wuauserv (Windows Update), bits (Background Intelligent Transfer Service), cryptsvc (Cryptographic Services) and msiserver (Windows Installer). The script stops them so their files are no longer in use, then starts them again after the cleanup.

Folder rename. C:\Windows\SoftwareDistribution holds downloaded updates and update history. C:\Windows\System32\catroot2 holds update signature data. Renaming both forces Windows to create fresh copies the next time it checks for updates. The old folders stay on disk as SoftwareDistribution.bak_<time> and catroot2.bak_<time>. Once everything works, you can delete them to free several gigabytes.

DISM and SFC (optional). DISM /Online /Cleanup-Image /RestoreHealth repairs the Windows component store from Microsoft’s servers. sfc /scannow then checks protected system files and replaces damaged ones. These are slow, which is why they only run with -DeepRepair.

Fix Windows update manually (without the script)

If you prefer to run the commands yourself, open Command Prompt as Administrator and run:

net stop wuauserv
net stop cryptSvc
net stop bits
net stop msiserver
ren C:\Windows\SoftwareDistribution SoftwareDistribution.old
ren C:\Windows\System32\catroot2 catroot2.old
net start wuauserv
net start cryptSvc
net start bits
net start msiserver

Then repair system files:

DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow

Restart and check for updates again.

Common Windows Update error codes

The script shows recent error codes. Here is what some of the most common ones usually mean.

Error codeCommon meaningWhat helps
0x80070422The Windows Update service is disabled or not runningThe script sets it back to Manual and restarts it
0x80070002 or 0x80070003Files missing or corrupt in the update cacheReset the cache; also check the date and time on your PC
0x80073712A component store file is missing or damagedRun with -DeepRepair
0x8024402C or 0x80072EE2Connection, DNS or proxy problemCheck your network, VPN and proxy settings
0x800F0922Often low disk space or a VPN or .NET conflictFree space, disconnect any VPN, retry
0x80070005Access deniedRun as Administrator; check security software

These are general guides. The same code can have more than one cause, so use the check-only output to narrow it down.

If it still does not work

  • Restart first. A pending restart blocks new updates.
  • Free disk space. Aim for at least 10 GB free on your system drive.
  • Check update policies. If the script reports policy overrides, your PC may be managed by work or school, or a “tweak” tool may have blocked updates.
  • Test your connection. A DNS or proxy problem looks like a Windows Update problem. See our network fixer guide for how to diagnose it.
  • Try the Microsoft Update Catalog. You can download a specific update (search by its KB number) and install it manually.
  • Use an in-place upgrade. If system files are badly damaged, reinstalling Windows over itself with the Media Creation Tool keeps your files and apps.

Frequently Asked Questions (FAQ)

Is it safe to rename the SoftwareDistribution folder?

Yes. Windows recreates it automatically. This script renames it instead of deleting it, so you keep a backup until you are sure everything works.

Will I lose my installed updates or files?

No. Installed updates stay installed and your personal files are not touched. Only the update history list is reset.

How long does the repair take?

The standard repair usually takes a minute or two. The deep repair with DISM and SFC can take 15 to 40 minutes depending on your PC.

Do I need to restart afterwards?

Yes. Restart, then check for updates again.

Does this work on Windows 10 and Windows 11?

The script uses standard Windows tools available on both. Yes. I tested it on Windows 11 24H2 and Windows 10 22H2. (Video Available on Byqus YouTube Channel)

Can I run the script without the -Execute switch?

Yes, and you should do that first. Without -Execute it only reports problems and changes nothing.

Why does Windows Update keep failing after the reset?

Check for low disk space, a pending restart, VPN or proxy settings, and update policies. Run the script again with -DeepRepair if system files may be damaged.

Conclusion

Most stuck or failing Windows Updates come down to a damaged update cache or a stopped service. The script above checks for those problems first, then resets the update components in a reversible way. Start with the check-only mode, apply the repair if needed, and restart.

If this guide helped, you may also like our other free tools: the PC Health Checker, the Disk Space Analyzer and the Network Fixer.

Disclaimer: Scripts are provided as is, without warranty. Back up important data and use at your own risk.



Watch on YouTube

Prefer video explanations? Explore practical, real-world tutorials and visual walkthroughs on our YouTube channel.


Leave a Comment

Scroll to Top