Several things to try.
While it works well most of the time, problems with Windows Update can be very, very frustrating. There’s often no specific fix for whatever specific situation you’re faced with, other than to “keep trying” or “let it run”…
…neither of which helps in many cases.
Fortunately, Microsoft has added a troubleshooter and also outlined what I’ll call the nuclear option: resetting Windows Update completely. Regardless of the problem, if it involves Windows Update, I suggest you give this a try.
Become a Patron of Ask Leo! and go ad-free!
Fixing Windows Update
If Windows Update is having problems, the best place to start is with Windows’ own built-in troubleshooter. If that doesn’t resolve the issue, there’s a Windows Powershell script to try. If that doesn’t do it, then there’s a series of command-line tools you can run manually. The latter two options re-initialize Windows Update’s view of what needs updating in cases where it has lost track.
Windows 10: Start with the troubleshooter
In Windows 10 & 11, click on the Start menu and type “troubleshoot” to search for the available troubleshooters. Click on Troubleshoot settings or Troubleshooting when it appears. In the resulting window, look for “Windows Update” in the right-hand pane. (You may need to scroll down to find it.)
Click on Run the troubleshooter to let Windows attempt to diagnose and fix any problems it detects.
If it resolves your issue, wonderful. But with software being as complex as it is, I don’t expect the troubleshooter to work in 100% of all cases. If it didn’t resolve your issue, or your edition of Windows does not yet include the troubleshooter,1 it’s time to reset.
A few notes before we proceed
#1: Following the instructions below incorrectly — heck, perhaps even following them correctly — could damage your Windows installation. I strongly recommend you take a complete image backup prior to performing these steps and be prepared to restore that image backup should something go wrong. Something shouldn’t go wrong, but an image backup will protect you should I be wrong about something not going wrong.
#2: By following the instructions below or downloading and using the scripts provided by either Microsoft or myself, you are assuming complete responsibility for the results. For all I know, there’s something special about your machine I cannot predict or account for. While it’s certainly not the intent, the instructions and/or scripts could render your computer unbootable. Once again, your best defense is note #1.
#3: Don’t just click and run any of the scripts mentioned below. Instead, download the file by right-clicking and saving it to a location on your computer. You’ll run those scripts from within an administrative PowerShell or Command Prompt. Since these are text files, you can examine their contents at will. Note that since they are considered executable files, your security software may need to be told to “allow” the download.
#4: Line wrapping: Since text can sometimes be wrapped to accommodate your display width, if a command is listed with no space between its lines:
they’re meant to be typed on a single line with a space between the text. In the example above, you would type:
Command more stuff
followed by the Enter key. If the commands have a blank line between them:
they’re two distinct commands, each entered on its own and each followed by Enter.
Next: Microsoft’s script for Windows 10
Microsoft has a Knowledge Base article, Windows Update – additional resources, that includes a section titled, “How do I reset Windows Update components?”
Unfortunately, it’s not mentioned that the script appears to need administrative privileges. Simply right-clicking on the downloaded file and clicking on Run in PowerShell will briefly flash a window in which the script runs but then fails due to lack of privileges.
As a result, the steps to run the script after downloading it actually are:
- Open PowerShell “as administrator”. In the Start menu, scroll down to locate Windows PowerShell, click on that to expand it, then right-click on the newly exposed Windows PowerShell in the submenu, and click on Run as administrator.3
- Type the command:
followed by the Enter key. Windows will print a one-word policy — most commonly “Restricted”. Note this, as you’ll need to type it in later.
- Enter the following:
Set-ExecutionPolicy -ExecutionPolicy Bypass
followed by Enter. Respond with Y when prompted for confirmation.
- Change directory to the folder containing the downloaded script. This will probably be your “Downloads” folder. Do this by typing:
CD \Users\<login name>\Downloads
followed by Enter, and where “<login name>” is replaced with your Windows login name.
- Type “.\” followed immediately by the name of the downloaded script, followed by Enter:
- After the script runs, enter the following:
Set-ExecutionPolicy -ExecutionPolicy <policy>
followed by Enter, and where “<policy>” is the policy displayed returned in step 2, above.
- Reboot your machine.
Hopefully this will correct your issues with Windows Update.
In theory, this script includes the steps listed below. If you’re not running Windows 10, or you just want to carefully execute the steps on your own, you can do so.
Finally: fix Windows Update manually
The steps and scripts below support Windows 7 and later. If you’re running Windows XP or Vista, the Microsoft article includes a few additional steps interspersed.4
Run Command Prompt as administrator
All the following steps require administrative privileges. It’s not enough that your log-in account be administrator; you need to run the Windows Command Prompt as administrator for those privileges to be in effect.
In the Start menu, locate the Windows System heading and click on it. Then right-click on Command Prompt. Click on More if the resulting sub-menu includes that, and then on Run as administrator.5
This will open an instance of Command Prompt with the administrative access required for what follows.
First, we’ll stop several Windows services. Type the following into the command prompt, each line followed by Enter:
net stop bits
net stop wuauserv
(Or download and run stop-services.cmd.)
Don’t worry if some of the services report an error that they’re not running.
Delete Download Manager files
Next, we’ll delete a set of files related to the Download Manager.
Del “%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat”
(Or download and run delete-qmgr-files.cmd.)
Reset software distribution and reset services
Microsoft recommends you perform this step only if running through these instructions without this step did not resolve the problem.
Ren %systemroot%\SoftwareDistribution\DataStore *.bak
Ren %systemroot%\SoftwareDistribution\Download *.bak
Ren %systemroot%\system32\catroot2 *.bak
sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)
sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)
What Microsoft doesn’t mention is that the first two commands will fail if they’ve been run before, meaning that if the backup folder “%systemroot%\SoftwareDistribution.bak” already exists, or the backup folder “%systemroot%\system32\catroot2.bak” exists, the rename will fail. If that happens, do not proceed until you have removed the pre-existing “.bak” folders manually. Since “%systemroot%” is typically “C:\Windows”, look for “C:\Windows\SoftwareDistribution.bak” and “C:\Windows\system32\catroot2.bak”, and either rename them to something else, or delete them. (You did take that image backup, right? :-)).
Here’s a batch file that includes those commands, but also pauses after the rename to give you an opportunity to abort: reset-software-distribution.cmd.
Enter the following commands exactly:
cd /d %windir%\system32
— or download and run register-dlls.cmd.
You will have to click an OK button for each one. In addition, several will fail. As unnerving as that may seem, it’s OK. Not every system is configured the same way, and thus not every DLL will be present.
Reset the network
Reset network components with the following commands:
netsh winsock reset
(Or download and run reset-network.cmd.)
Now we restart the services we stopped earlier.
net start bits
net start wuauserv
(Or download and run start-services.cmd.)
Naturally, much of what we’ve done will require a reboot to take final effect.
What did we just do?
After all that mumbo-jumbo, you’re probably wondering what you just did, be it manually or via a script.
The best analogy I can come up with is clearing your browser cache. Just as your web browser tries to avoid multiple downloads and generally speed up your browsing by keeping many things in a cache on your machine’s hard disk, Windows Update does something similar. Rather than re-analyzing, slowing down your system, and perhaps even downloading information repeatedly, it caches much of what it learns about your system on disk.
And just like the browser, sometimes the cache can get “confused”.
We’ve simply cleared out the cache and reset a few things to known states so Windows Update can start with a clean slate.
(To be clear, browser caches and the Windows update cache are completely unrelated to one another; just the concepts are similar.)
Subscribe to Confident Computing! Less frustration and more confidence, solutions, answers, and tips in your inbox every week.
I'll see you there!
Footnotes & References
1: Naturally, I recommend you update to a version that does, but of course that requires Windows Update to work.
2: It’s unclear if this does exactly what the troubleshooter did, or something more. Since we don’t know for sure, it’s worth a try.
3: In Windows 10 and 11, if your system is so configured, you may instead be able to right-click on the Start menu and then click on Windows PowerShell (Admin).
4: In Windows 10 and 11, if your system is so configured, you may instead be able to right-click on the Start menu and then click on Command Prompt (Admin).
5: Though, to be fair, Windows Update isn’t of much use on these no-longer-supported operating systems.