How Do I Fix Windows Update?


I returned from vacation and found that Windows Update would not download any of 90 available updates (even though it sat for many hours saying “downloading” nothing was coming). I eventually used the Windows Readiness program and was able to get 15 or so downloaded and installed, but trying the next group again, it is not downloading anything. There is no error message, just no action at all.

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.

Windows 10: Start with the troubleshooter

In Windows 10, click on the Start menu and type “troubleshooter” to search for the available troubleshooters. Click on Troubleshoot settings 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 10 does not yet include the troubleshooter, 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 the previous 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:

Command
more stuff

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:

Command 1

Command 2

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?”

This section begins with a PowerShell script you can download and run.

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 fails due to lack of privileges.

As a result, the steps to run the script after downloading it actually are:

  1. 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.
  1. Type the command:

Get-ExecutionPolicy

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.

  1. Enter the following:

Set-ExecutionPolicy -ExecutionPolicy Bypass

followed by Enter. Respond with Y when prompted for confirmation.

  1. 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.

  1. Type “.\” followed immediately by the name of the downloaded script, followed by Enter:

.\Reset-WindowsUpdate.ps1

  1. 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.

  1. 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, 8.1, and 10. If you’re running Windows XP or Vista, the Microsoft article includes a few additional steps interspersed.

Run Command Prompt as administrator

All of the steps that follow 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.

Running Command Prompt as Admin in Windows 10
Running Command Prompt as Admin in Windows 10 (click for larger image).

This will open an instance of Command Prompt with the administrative access required for what follows.

Stop Services

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.

Re-register DLLs

Enter the following commands exactly:

cd /d %windir%\system32

regsvr32.exe atl.dll

regsvr32.exe urlmon.dll

regsvr32.exe mshtml.dll

regsvr32.exe shdocvw.dll

regsvr32.exe browseui.dll

regsvr32.exe jscript.dll

regsvr32.exe vbscript.dll

regsvr32.exe scrrun.dll

regsvr32.exe msxml.dll

regsvr32.exe msxml3.dll

regsvr32.exe msxml6.dll

regsvr32.exe actxprxy.dll

regsvr32.exe softpub.dll

regsvr32.exe wintrust.dll

regsvr32.exe dssenh.dll

regsvr32.exe rsaenh.dll

regsvr32.exe gpkcsp.dll

regsvr32.exe sccbase.dll

regsvr32.exe slbcsp.dll

regsvr32.exe cryptdlg.dll

regsvr32.exe oleaut32.dll

regsvr32.exe ole32.dll

regsvr32.exe shell32.dll

regsvr32.exe initpki.dll

regsvr32.exe wuapi.dll

regsvr32.exe wuaueng.dll

regsvr32.exe wuaueng1.dll

regsvr32.exe wucltui.dll

regsvr32.exe wups.dll

regsvr32.exe wups2.dll

regsvr32.exe wuweb.dll

regsvr32.exe qmgr.dll

regsvr32.exe qmgrprxy.dll

regsvr32.exe wucltux.dll

regsvr32.exe muweb.dll

regsvr32.exe wuwebv.dll

— 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).

Restart services

Now we restart the services we stopped earlier.

net start bits

net start wuauserv

(or download and run start-services.cmd).


Finally, Reboot

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.)

Originally published as How Do I Fix Windows Update? on Ask Leo!