Clean Up the WinSxS Folder

Configuring RDP/RDS Sessions Limits (Timeouts) on Windows
June 15, 2023
Windows 2016 RDP Licensing Problem
August 28, 2023

Clean Up the WinSxS Folder

  1. Task Scheduler
  2. Dism.exe
  3. Disk Cleanup
  4. Related topics

This topic is about the different ways to reduce the size of the WinSxS folder on a running Windows 10, or later, installation.

Don’t delete the WinSxS folder, you can instead reduce the size of the WinSxS folder using tools built into Windows. For more information about the WinSxS folder, see Manage the Component Store.

The operating system automatically reduces the size of the WinSxS folder by using methods similar to the ones described in this topic. Windows also uses internal processes to reduce the size of the WinSxS folder, such as uninstalling and deleting packages with components that have been replaced by other components with newer versions. Previous versions of some components are kept on the system for a period of time, allowing you to rollback if necessary. After a period of time, these older components are automatically removed from the installation.

You can also reduce the size of a Windows image using some of the same techniques, as discussed in Reduce the Size of the Component Store in an Offline Windows Image.

To learn about finding the size of your WinSxS folder, see Determine the actual size of the WinSxS folder.

 Warning

Deleting files from the WinSxS folder or deleting the entire WinSxS folder may severely damage your system so that your PC might not boot and make it impossible to update.

  You have a number of ways to start the cleanup of the component store, which use a combination of package deletion and component compression to clean up the WinSxS folder:

Task Scheduler

The StartComponentCleanup task automatically cleans up components when the system isn’t in use. 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 RunWindows Command PromptCopyschtasks.exe /Run /TN "\Microsoft\Windows\Servicing\StartComponentCleanup"  NoteThe StartComponentCleanup task can also be started from the command line.

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 or later 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, run:Windows Command PromptCopyDism.exe /online /Cleanup-Image /StartComponentCleanup

Use the /ResetBase switch with the /StartComponentCleanup parameter

  • Using the /ResetBase parameter together with the /StartComponentCleanup parameter of DISM.exe on a running version of Windows 10 or later removes all superseded versions of every component in the component store.From an elevated command prompt, run:Windows Command PromptCopyDism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase  WarningAll existing update packages can’t be uninstalled after this command is completed, but this won’t block the uninstallation of future update packages. 

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.

Run Disk Cleanup to delete system files

Manage the Component Store

Determine the Actual Size of the WinSxS Folder

Reduce the Size of the Component Store in an Offline Windows Image

How to address disk space issues that are caused by a large Windows component store (WinSxS) directory