Chotaire Wiki

Stuff you didn't know

User Tools

Site Tools


windows10-winsxs

Clean up the WinSxS folder

Using the Disk Cleanup Tool regularly is a nice thing to strip down the WinSXS folder, however for sysprepping machines this is not sufficient as it will skip the updates from the past 30 days. I recommend running Disk Cleanup tool first and then run DISM from an elevated command prompt (cmd.exe as an Administrator) to get rid of the rest:

Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

For the sake of completion, here is the full documentation on how to clean your WinSxS:

Task Scheduler

The StartComponentCleanup task was created in Windows 8 to regularly clean up components automatically when the system is not in use. This task is set to run automatically when triggered by the operating system. When run automatically, the task will wait at least 30 days after an updated component has been installed before uninstalling the previous versions of the component.

If you choose to run this task, the task will have a 1 hour timeout and may not completely clean up all files.

Run the StartComponentCleanup task in Task Scheduler to clean up and compress components

  1. If Task Scheduler is not open, start the Task Scheduler. For more information, see Start Task Scheduler.
  2. Expand the console tree and navigate to Task Scheduler Library\Microsoft\Windows\Servicing\StartComponentCleanup.
  3. Under Selected Item, click Run
schtasks.exe /Run /TN "\Microsoft\Windows\Servicing\StartComponentCleanup"

Dism.exe

The /Cleanup-Image parameter of Dism.exe provides advanced users more options to further reduce the size of the WinSxS folder. For more information, see DISM Operating System Package Servicing Command-Line Options.

Use the /StartComponentCleanup parameter

Using the /StartComponentCleanup parameter of Dism.exe on a running version of Windows 10 gives you similar results to running the StartComponentCleanup task in Task Scheduler, except previous versions of updated components will be immediately deleted (without a 30 day grace period) and you will not have a 1-hour timeout limitation.

From an elevated command prompt, type the following:

Dism.exe /online /Cleanup-Image /StartComponentCleanup

Use the /ResetBase switch with the /StartComponentCleanup parameter

Using the /ResetBase switch with the /StartComponentCleanup parameter of DISM.exe on a running version of Windows 10 removes all superseded versions of every component in the component store.

From an elevated command prompt, type the following:

Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
All existing service packs and updates cannot be uninstalled after this command is completed. This will not block the uninstallation of future service packs or updates.

Use the /SPSuperseded parameter

To reduce the amount of space used by a Service Pack, use the /SPSuperseded parameter of Dism.exe on a running version of Windows 10 to remove any backup components needed for uninstallation of the service pack. A service pack is a collection of cumulative updates for a particular release of Windows.

From an elevated command prompt, type the following:

Dism.exe /online /Cleanup-Image /SPSuperseded
The service pack cannot be uninstalled after this command is completed.

Additional cleaning

Disk Cleanup

You can use Disk Cleanup to reduce the number of unnecessary files on your drives, which can help your PC run faster. It can delete temporary files and system files, empty the Recycle Bin, and remove a variety of other items that you might no longer need. The option to cleanup updates helps reduce the size of the component store. To delete system files run the steps as provided in Delete files using Disk Cleanup.

Delete unused Windows features and roles

Read this article to free at least 4GB of additional diskspace: Windows Server 2019: Remove unused features and roles from component store



windows10-winsxs.txt ยท Last modified: 2020/02/01 19:18 by chotaire