WinSXS folder is the component store of Windows vista and later operating systems. Windows OS stores all its core components to WinSXS directory. The WinSXS folder is the only location that the core system components found on the system and all the system files you see in their usual locations, in the windows directory structure, are hard linked back to the WinSXS folder. WinSXS folder is the only location that OS stores its components; everything else are just hard links. To prove the later point you can use the fsutil to check the hardlinks of a system file.

WinSXS cleanup

So, WinSXS starts large! But why is growing larger? The answer is updates. Every time a binary updates, a new version of the whole component is released and the old version is retained for reliability reasons in the component store. The updated version of a component is projected to the system (hardlinked) but the old version is retained with no hardlinks. This is the reason an update can be safely uninstalled from the system. If you uninstall an update from the system the next higher version of the component is used and other component changes may also be triggered as a result of dependencies.

Note, that WinSXS folder sometimes is perceived to be much larger than actually is. This misconception is because windows explorer and dir command are not aware of the difference between actual files and hardlinks. To have a better view of the disk space consumed by WinSXS you can use the SysInternal’s du utility (du -v c:\windows\winSXS).

It is obvious that you cannot perform a WinSXS cleanup manually because it will cause problems to the OS. You can take advantage though of some features Windows 8 and Windows Server 2012 have introduced to cleanup some files.

Features on Demand

Windows 8 and windows Server 2012 introduced a new feature called “features on demand”. Features on demand are simply a feature that allows you to remove role and feature payloads from the OS to conserve diskspace. By default, windows OS stores under %windir%\WinSXS folder all feature and role payloads, either installed or not, making an OS able to add features and roles without the need of an installation source.

In windows Server 2012 you can remove those payloads by using the powershell command uninstall-windowsfeature with the -remove switch. In case you want later to install a feature of which you previously removed its payload from the system; you can use the install-windowsfeature command. Install-windowsfeature will try to install a windows feature from the following source locations: local winSXS store or Windows Update in case of a payload removal from the local WinSXS store. You can also specify the -source switch to instruct the command to seek payloads from the alternate source path specified instead of windows update.

To cleanup all windows feature payloads from the system you currently don’t use, execute the following command:

Get-WindowsFeature | where-object{$_.Installed -eq 0 -and $_.InstallState -eq 'Available'} | uninstall-windowsfeature -remove

 

The first part of the command gets the windows features that are not installed on the system and have its payloads available and pipes it in the uninstall-windowsfeature command for removal.

In case of windows 8 the powershell cmdlet above won’t work; thus it is required to use dism.exe instead, which can also be used in Windows 2012. To get features installation status:

DISM /online /get-features /format:table

 

To get a feature state status:

DISM /online /get-featureinfo /featurename:TFTP

 

To remove a feature:

DISM /online /disable-feature /featurename:TFTP /remove

 

 

WinSXS cleanup from superseded components

In order to perform a WinSXS cleanup, you can remove any backup files created during the installation of a service pack by using the following command:

dism /online /cleanup-image /SPSuperseded

 

Note, that after you execute that command you will no longer be able to uninstall the service pack.

You can further perform a WinSXS cleanup by removing any superseded components:

dism /online /cleanup-image /StartComponentCleanup
dism /online /cleanup-image /StartComponentCleanup /ResetBase (Windows 2012R2 and Windows 8.1 only)

 

Note, that the /ResetBase switch can only be used in Windows 2012R2+ and Windows 8.1+ in order to reset the base of superseded components and optimize the WinSXS cleanup process

What about a user interface (UI)?

Natively in windows 8 and after KB2852386 update in windows 7, disk cleanup utility supports cleaning the winSXS store. Just right mouse click your system drive, select properties and press disk cleanup. From that point forward select cleanup system files where you can select the Windows Update Cleanup option which cleans up the WinSXS cache.

Lefteris Karafilis

ICT Professional at Free Lancer
Lefteris is an experienced information and technology (IT) professional / infrastructure architect with an extensive background in the small-to-medium project-based business.

Since 2002 Lefteris has been improving the information and technology set-ups of small and medium businesses to an ideal level, therefore reducing your company's operating costs and increasing your staff’s effectiveness.

Unlike other ICT professionals and service providers who focus on plain-vanilla support, we focus on your company's improvement by the use of technology.

6 Responses to WinSXS cleanup in Windows 2012 and Windows 8

  • Thanks for these tips, but I have an issue. After entering:

    dism /online /cleanup-image /StartComponentCleanup

    in an admin console, dism loads then passes an error:

    The cleanup-image option is unknown.

    I have cycled dism for options on this same console/system ie:

    dism /online /?

    does indeed list /cleanup-image as an option. I’ve gathered that this is perhaps due to ‘because there is nothing to cleanup, but my winsxs is a ridiculous size, unecessary I imagine. Can you advise how I might rectify this?

    • Hello Chris, which version of windows are you using? Note, that /startcomponentcleanup is a Windows 8 feature only.

      • Yeah that’s what I thought, I am indeed on Windows 8 (x64).

      • Oh it seems to be working now, although my winsxs dir is still about half of my install size at around 10GB.

        • I am glad it is working for you know. Have you try to disable some “features on demand” to save more space?

  • I’ve disabled quite a few features now but I’m still only getting rid of a few hundred megabytes using dism, even after ensuring things are tight using the health switches (/restorehealth etc, which took a long time to complete). There appears to be a lot of updates on my system which dism does not want to flush. I ended up deleting my reserve.tmp file from winsxs which was in excess of 3gb, and I’m just going to live with that for now and get back to Linux.

Leave a Reply

  • 2+1 Ways to find your piece of mind. With a fixed monthly cost, unlimited support and access to partners network.
    Read More
Related Posts
Recent Posts
Top Posts
  • 2+1 Ways to find your piece of mind. With a fixed monthly cost, unlimited support and access to partners network.
    Read More