Cleanup of the infamous WinSxS folder

The never ending battle of keeping the Windows folder size in check seems to have a favorable outcome. I’ve always resented the fact that on every PC/laptop I owned, in time, I watched space being eaten away by Windows keeping all the previous installer files. Even with drives getting bigger and cheaper these days, it is still a very good practice to do a routine cleanup from time to time.

There are many tools out there that can show you how much true space your folder structure is taking up but the one I recommend the most is WinDirStat. Not gonna go into details but running it will show you a lot more wasted space than just WinSxS folder. However, the scope of this article is just keeping Windows folder size in check so let’s get on with it.

How to determine the size of WinSxS?

Luckily, for latest versions of Windows (10+), Microsoft has implemented a clean and SAFE option of analyzing the WinSxS folder size. It is accomplished via the Deployment Image Servicing and Management tool (in short DISM) which can be run from an elevated Command Prompt (run as Administrator is a must).

All you need to do is to run the following command:

Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore

The expected outcome is to get information on the actual WinSxS folder size, the “cleanable” size (which is basically the size of the old backups and disabled windows features) and a recommended action, which in most cases will most likely be to run the cleanup tool ๐Ÿ˜€

Deployment Image Servicing and Management tool
Version: 10.0.22621.2792

Image Version: 10.0.22631.3447

[===========================99.4%========================= ]

Component Store (WinSxS) information:

Windows Explorer Reported Size of Component Store : 12.79 GB

Actual Size of Component Store : 12.12 GB

    Shared with Windows : 6.93 GB
    Backups and Disabled Features : 5.18 GB
    Cache and Temporary Data :  0 bytes

Date of Last Cleanup : 2024-04-23 09:36:33

Number of Reclaimable Packages : 2
Component Store Cleanup Recommended : Yes

The operation completed successfully.

Looks like DISM is suggesting that I run a Component Store Cleanup :D… no surprise there …

Does WinSxS get cleaned-up automatically?

I have to be kind to Microsoft and say that they do claim that there is an automatic cleanup of WinSxS folder that is run via a scheduled task. You can find the task if you open Control Panel -> Schedule Tasks (Windows Tools category) -> Task Scheduler Library -> Microsoft -> Servicing -> StartComponentCleanup.

It seems for me it ran 2 days ago and the operation was a big success ๐Ÿ˜€

I am guessing, according to Microsoft documentation, that the reason it didn’t clean-up the folder automatically is because the service is restricted to cleaning up only components/back-ups older than 30 days ago. When it comes to Windows … i don’t know … maybe it is true.

Regardless, I needed to be fair and tell you that apparently there is a clean-up of WinSxS that is being run automatically and, according to Microsoft, you should no longer expect that Windows folder grows to insane sizes anymore … Hope that’s true…

How to safely clean-up WinSxS folder?

Since my trust over the years has been rather shaky, when it comes to Windows, I decided to run a manual cleanup of the WinSxS folder. A word of caution:

phew … now that I know you’re not gonna do anything crazy, let’s get to the SAFE option of cleaning up WinSxS. And we go back to the previously mentioned DISM tool which Microsoft has so kindly provided. Another word of caution: manually running the DISM cleanup sequence will DELETE any previous backups/disabled features, regardless of when they were created. This means that if you just updated your Windows 5 minutes ago it is NOT a good idea to cleanup WinSxS folder manually since, if something went wrong during the upgrade, you will lose any way to revert to previous component’s version.

With that being said, all you need to do is to run (in an elevated Command Prompt) the following command:

Dism.exe /online /Cleanup-Image /StartComponentCleanup

This will be a while, depending on how big the size of the WinSxS folder is and how many old components need to be deleted. The outcome should be something like this:

Deployment Image Servicing and Management tool
Version: 10.0.22621.2792

Image Version: 10.0.22631.3447

[==========================100.0%==========================]
The operation completed successfully.

If you really don’t take their word for it, just run the DISM analyze command again. In my case the result was:

Deployment Image Servicing and Management tool
Version: 10.0.22621.2792

Image Version: 10.0.22631.3447

[===========================99.3%========================= ]

Component Store (WinSxS) information:

Windows Explorer Reported Size of Component Store : 9.04 GB

Actual Size of Component Store : 8.80 GB

    Shared with Windows : 6.91 GB
    Backups and Disabled Features : 1.89 GB
    Cache and Temporary Data :  0 bytes

Date of Last Cleanup : 2024-05-01 10:27:48

Number of Reclaimable Packages : 0
Component Store Cleanup Recommended : No

The operation completed successfully.

Looks like I reclaimed 4Gb of space, not bad, not great ๐Ÿ™‚ but hey … I once had a WinSxS folder size of 100Gb+ and that was truly impressive (in a negative way of course).

It’s worth mentioning that it may be wise, from time to time, to also perform a Disk Cleanup. Make sure that you select “Cleanup system files” option on the initial screen. I got another 5 Gb right there just because of old “System error memory dump files“. I wonder why those were there …

As usual, I hope this helped you and that you are a tiny bit happier with your Windows machine!


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *