Reset Windows Update with a Single BatchPatch Remote Command

We recently received a request to integrate the following into BatchPatch, so that with a single click a user could perform the following actions on numerous target computers:

  1. Stop the Windows Update service by running the following command:
    NET STOP WUAUSERV
  2. Rename the C:\Windows\SoftwareDistribution folder to C:\Windows\SoftwareDistribution.old
  3. Start the Windows Update service by running the following command:
    NET START WUAUSERV

Currently there is not a built-in macro in BatchPatch for the above items, but the good news is that it’s easy to create your own one-click method to perform the tasks.

Before I explain how to easily incorporate this macro into your own BatchPatch instance, let’s briefly discuss the impact and implications of performing these actions. Essentially, it’s only step 2 that really *does* anything destructive, but you can’t perform step 2 without first stopping the Windows Update service. So, step 1 stops the Windows Update service, step 2 renames the SoftwareDistribution folder to SoftwareDistribution.old, and then step 3 restarts the Windows Update service. When it starts, Windows will automatically recognize that there is no longer a SoftwareDistribution folder in C:\Windows, thereby forcing it to actually create a new one from scratch.

Windows stores downloaded updates in the SoftwareDistribution folder along with a database that retains history information about updates that have previously been installed. If you have downloaded Windows updates but have not yet installed them, they will be stored in this folder until they are installed. However, if you then delete the contents of the folder or rename the folder, thereby forcing Windows to create a new folder from scratch, your downloaded but not yet installed updates will be deleted, requiring you to download them again from scratch before you can install them. Additionally, much of the Windows Update history information that Windows retains about updates that have previously been installed is stored in a database that is housed in this folder. If the folder has been renamed or deleted, you may no longer be able to determine when a particular update was previously installed. In Windows 10 it has already become increasingly difficult, or in some cases impossible, to determine when old updates were installed, because each time you install a feature update, most of this update history information is wiped since most feature update installations are treated by Windows like a complete operating system upgrade / reinstall. That said, the loss of history information that occurs when the SoftwareDistribution folder is renamed or deleted may not be such a big deal to you since you’re probably going to lose some of that information at some point in the future anyway (if you’re running Windows 10).

Many forums on the web will describe the process of renaming or deleting the SoftwareDistribution folder as a good way to reset the Windows Update components. We have even occasionally suggested it in our forums. Before you go about doing this, you should make sure you really want to do it. It will certainly fix certain issues at certain times, but I wouldn’t recommend using it as a “first-try” option. Usually this process should be reserved for a last resort attempt at fixing your issue. Also note, it generally always makes more sense to rename the folder as opposed to delete it altogether because if on the off chance it creates a problem, you can always revert back to the renamed folder, if need be. If it works without issues to solve your problem, then you can certainly just move forward and delete the old folder that you had renamed so that it’s no longer taking up space on your hard drive.

OK, so to perform the above operations as a single-click task in BatchPatch, you’ll need to do the following:

  1. Select ‘Actions > Execute remote process/command > Create/modify remote commands’
  2. In the window that appears, click ‘Add Row’ and then enter the following syntax into the ‘Command’ field (you can use any title that you like in the ‘Title’ field):
    NET STOP wuauserv & MOVE C:\Windows\SoftwareDistribution C:\Windows\SoftwareDistribution.old & NET START wuauserv

  3. That’s it! Now when you are ready to execute the task on target computers, simply highlight the desired rows in the BatchPatch grid, then select ‘Actions > Execute remote process/command > Execute saved remote commands’. Find your command in the menu and click on it to execute it on the selected target hosts.
This entry was posted in Blog, General, Tutorials and tagged , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.