Use DISM to cleanup WinSxS after Windows Update

After making a reference image of a Windows 8.1 installation and updating it, we wanted to clean up the installation. There are a few methods that can be used, such as using Disk Cleanup GUI and select Windows Update Cleanup, or run the StartComponentCleanup (found under MicrosoftWindowsServicing) in Task Scheduler but using the CLI to achieve this is much cooler and you have stronger options.


As shown in the picture, we have updated the computer with all latest patches with PowerShell, see my previous post. And after no more updates areĀ available we used DISM to clean up everything. Here I will show 3 options to clean up the system:

This option is the same as using the Task Scheduler method, but now the updated components are immediately deleted. If had used the task, it will only clean up if the updated components are longer then 30 days installed on the system.

This one is my favorite to use after installing a new system. The /ResetBase switch option also deletes all superseded versions of every component in the component store. A warning if you want to use it on systems in production: All existing service packs and updates cannot be uninstalled after this command is completed. But this option will not block the uninstallation of service packs or updates installed later on.

This one is useful after installing a service pack on your system. The /SPSuperseded switch option removes all backup components needed to uninstall the service pack. Also a sidenote here, you cannot remove the service pack anymore after using this command.

Of course, there are more options possible with DISM and maybe you need to change the switch options a bit, here is the help output for /Cleanup-Image:

Update: Windows 10 build 10547 output of the DISM /Cleanup-Image command:

It looks like only the version number is altered and that the same commands can be used in Windows 10.