Batch Uninstall Windows Updates

This post shows how to programmatically automatize the batch uninstall of multiple Windows Update hotfixes. The code samples are in AutoHotKey syntax, and you can get the full source code, as well as compiled executables ready to run, on the Windows Updates Uninstaller Utility online repository.

Listing the Updates

The simplest way to get a list of the installed Windows Updates is through WMIC, which is an internal Windows command-line interface for accessing management functions. Using the QFE module, we can generate a list by running the following command, for example from the Command Console: wmic qfe get "HotFixID" /format:table

This will list the installed updates directly in the console, like this: updates list on console

It’s easier to parse them from a text file, and luckily our friend QFE can do that for us too with the following command:

wmic qfe list brief /format:texttablewsys >"%Path_of_the_text_file%" where %Path_of_the_text_file% is what it says, the path of the text file to be created, such as C:\hotfix.txt for example, or wherever. When listing in a file, it won’t list individual columns but the whole table, so you’ll need to use character offsets when parsing columns.

Uninstalling the Updates

To uninstall each update, the easiest way is to use WUSA, which is a built in Windows utility for managing Windows Updates. Since you already have a list of the installed updates, you just need to extract the hotfix ID number from each row, and run the following command for each update:

wusa.exe /kb:%HotfixId% /uninstall /quiet /norestart where %HotfixId% is the hotfix ID number. For example, to uninstall update KB279503 you need to run the following:

wusa.exe /kb:279503 /uninstall /quiet /norestart and so on. Since uninstalling each update takes time, you should wait for one uninstall to end before beginning the next one. If you’re using AutoHotKey, you can simply use the RunWait command and it will wait for each execution to finish before starting the next one.

Putting it all together

The essence is simple: get the list of updates, parse it to retrieve the hotfix IDs, and uninstall them one by one. If you’re into AutoHotKey, it’s pretty easy to do, as you can see at the Windows Updates Uninstaller Utility online repository. There you’ll find an AutoHotKey implementation with a basic GUI, in both source-code and compiled executable form, so you can toy with the code or use as-is.