Not many of you may know this, nor has this been blogged anywhere – yet; but Windows 11/10/8.1/8 lets you safely clean up the WinSxS folder. In fact, you can even automate WinSxS folder cleanup using the Task Scheduler. The WinSxS folder, which stands for ‘Windows Side By Side’, is a Windows native assembly cache with Libraries which are being by multiple applications being stored there. It is the location for storing Windows Component Store files.
Some common questions which Windows users asked were – Is there a way to clean up the WinSxS folder so as to reduce its size? Can I delete the WinSxS folder? Or move WinSxS folder to another drive. The short answer, as we had seen in the earlier post was: No.
WinSxS folder cleanup
In Windows 11/10/8.1/8, however, things have become easier. Windows will automatically reduce the size of the WinSxS. These methods include internal processes, such as uninstalling and deleting packages with components that have been replaced by other newer components. Previous versions are then kept for a period, after which they are automatically removed.
We saw that Windows 8.1 introduced a new command-line option for DISM.exe, /AnalyzeComponentStore. Running this command, will analyze the WinSxS folder and tell you whether a Component Store Cleanup is recommended or not.
Windows 11/10/8 offers a number of ways to cleanup of the WinSxS folder which includes the Windows Component Store. It may compress certain files, or it may delete some packages. Let us see how you can clean up the WinSxS folder in these latest versions of the Windows operating system. There are three ways how you can do it.
1] Using StartComponentCleanup
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.
To run it, open Task Scheduler and navigate to the following task:
Task Scheduler Library\Microsoft\Windows\Servicing\StartComponentCleanup
In the right pane, under Selected Items, you will see Run. Click on it to start the StartComponentCleanup task.
This will start a process called TiWorker.exe or Windows Modules Installer Worker. You will not see any confirmation dialog box that the process has been started, but you will be able to see it in the Task Manager – and feel a lot of hot air coming out of your laptop’s vent! By default, in Windows 10/8, if this task runs for more than 1 hour, it will terminate automatically. To end this process, you can click on End. You will, in this case, see Windows asking you for confirmation: Do you want to end all instances of this task. Click Yes.
You may run it manually, or you may schedule it to run, say every month using the StartComponentCleanup command, to clean up and compress the components. You may automate the process by setting up a Trigger for the task to run using the Task Scheduler.
Alternatively, you can also run the StartComponentCleanup task using an elevated Command Prompt, using the following command:
schtasks.exe /Run /TN "\Microsoft\Windows\Servicing\StartComponentCleanup"
If you are successful, you will see a SUCCESS message returned.
2] Using Deployment Image Servicing and Management
Using DISM you can configure and update Windows features, packages, drivers and so on. The /Cleanup-Image parameter of Dism.exe, will provide you with advanced options to reduce the size of the WinSxS folder, writes TechNet.
A) Using the /StartComponentCleanup parameter of Dism.exe on a running version of Windows 8.1 gives you similar results to running the StartComponentCleanup task in Task Scheduler.
Open an elevated command prompt, type the following and hit Enter:
Dism.exe /online /Cleanup-Image /StartComponentCleanup
B) If you use the /ResetBase switch with the /StartComponentCleanup parameter, you will be able to remove all superseded versions of every component in the component store.
From the elevated command prompt, type the following and hit Enter:
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
C) If you want to reduce the amount of space used by a Service Pack, use the /SPSuperseded parameter of Dism.exe on a running version of Windows 8.1 to remove any backup components needed for the uninstallation of the service pack.
From the elevated command prompt, type the following and hit Enter:
Dism.exe /online /Cleanup-Image /SPSuperseded
Do note that if you carry out this command, you will not be able to uninstall existing service packs and updates.
3] Disk Cleanup Tool
Home users should stick to using the Disk Cleanup Tool. Open the Disk Cleanup Utility and click on the Clean System Files button. You will see the option for Windows Update Cleanup. Check this option. This will help reduce the size of the component store.
Do note that deleting files from the WinSxS folder or deleting the entire WinSxS folder may damage your system and make it unbootable. You may not also be able to install, uninstall or update Windows components, so exercise utmost precautions. For regular Windows users, you may create a system restore point first and then try Method 1 or Method 3 mentioned above. Method 2 is for advanced users.
Windows 7 users too can now use the Windows Update Cleanup option in the Disk Cleanup tool.