How to clean up WinSxS folder to save Space In Windows 10

The WinSxS folder, also known as the Component Store, contains system repositories and is a crucial part of the Windows environment. With time, this folder keeps growing without any limit and can take up a heap of unnecessary space on your hard drive.

This article discusses how you can save up that space without affecting the critical system files by safely deleting the unwanted files within the WinSxS folder.

What is the WinSxS folder

The WinSxS folder contains files such as DLLs, binaries, and other XML files that are used by the device. It also contains the information and files required to install Windows features. Each time your Windows gets an update, it is installed on your computer while the old ones are shifted to the WinSxS folder. This is also important to prevent the system from crashing by providing compatibility or to revert to old files in case of a system restore.

This is why the WinSxS folder keeps increasing in size over time. This folder can be found on the following path:
C:\Windows\WinSxS

As you may find, the folder has a list of sub-folders and files that are used by the system.

winsxs repositories

How to check the size of the WinSxS folder

You can check the size of the folder through its properties in File Explorer. However, that is the actual size of the folder and not the one you can make available, since everything in the folder cannot be deleted to make space.

Along with cache, temporary files, backup and restore data, other critical files are also present. The properties bar does not indicate each individual category of the files within the WinSxS folder.

properties 1

To check the size of each component storage within this folder, perform the following:

  1. Open Command Prompt as an Administrator.
  2. Enter the following command:
    Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
  3. Now let the system scan the WinSxS folder and it will then display a list of the components and their sizes on the command-line interface.
    cmd size

You now have complete information on what WinSxS contains and what the size of each component is. We can now use this information to free up 1.14 GB (Backups and Disabled features) of unnecessary files and folders within WinSxS.

WinDirStat is a wonderful program that can calculate and show the folder structure and size of each drive in a visual way. To check the size of WinSxS, please run WinDirStat as administrator.

How to clean up WinSxS folder using Disk Cleanup

The Disk Cleanup tool is built into Windows 10 which can be used to perform safe operations to remove unnecessary system files. No critical system files are affected by using this utility, as opposed to deleting the WinSxS sub-folders manually using File Explorer, which poses a significant threat to Windows functionality.

Follow the guide below to perform this operation:

  1. Search for Disk Cleanup in the Start Menu and run it. (Note: Do not run as an Administrator)
  2. On the Drive Selection popup, select C: from the drop-down menu and click Ok.
    select c
  3. On the next screen, click on Clean up system files.
    clean up system files
  4. The Drive Selection window will pop up again. Select C: again and click Ok.
  5. Now select the files you wish the tool to clean by checking the boxes next to them, and then click Ok.
    check boxes 1
  6. On the confirmation dialog box, click Delete files. The operation will then begin and safely remove all unnecessary files.
    operation running

Although some of the unwanted files have been removed from the WinSxS folder, there is still a possibility to increase the available space even further. If required, move onto the next step.

How to clean up the WinSxS folder by removing Optional Features

Since the WinSxS folder also contains repositories for the optional features, you can create more space by removing the ones that are disabled, and you think you would not need it.

Perform the following to remove one feature at a time.

  1. Open Command Prompt as an Administrator.
  2. To find out the names and statuses of the current Optional Features in Windows 10, enter the following command:
    DISM.exe /Online /English /Get-Features /Format:Table
    list of features
  3. Now scan through the list and note the ones you think you do not need, and then enter the following command:
    DISM.exe /Online /Disable-Feature /Featurename:TFTP /Remove
    You may replace TFTP with a choice of your selected feature to delete it.
    cmd disable feature
  4. Repeat the last step to remove all the repositories from the system relating to the Optional Features.

If you check the Optional Feature status again by running the same command, you will see that the Status has changed from Disabled to Disabled with payload removed.
with payload removed

How to compress the WinSxS folder to save space

The WinSxS folder can also be compressed, if not deleted. The compression of the folder would save a significant amount of space while having everything available. This method would not involve removing or deleting anything. However, a con of the compression method would be that the system would perform an additional step or compression and decompression each time it needs to access the folder.

This would also affect the time it takes to perform these functions. Nonetheless, the time difference is not much as Windows 10 performs these functions quite fast.

The process involves starting and stopping some services, as well as changing the ownership of certain files and folders. Therefore it is recommended to create a system restore point before proceeding any further.

  1. Launch the Command Prompt as an Administrator.
  2. Enter the following commands one after the other to stop the associated services and disable them from automatically rebooting:
    1. sc stop msiserver
    2. sc config msiserver start= disabled
    3. sc stop TrustedInstaller
    4. sc config TrustedInstaller start= disabled
  3. Now we must back up the Access Control Lists (ACLs) of all the files and folders. Enter the following command:
    icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS_NTFS.acl" /t
    This will generate a text file with plain text, which will later be used to restore the default ACLs. This step might take a few seconds as there are a number of files to scan.
  4. Now assign the current user as the owner of WinSxS:
    takeown /f "%WINDIR%\WinSxS" /r
    This will assign ownership recursively, meaning that all sub-folders and files will also be affected.
  5. Now assign the current user full control of the WinSxS folder with the following command:
    icacls “%WINDIR%\WinSxS” /grant “%USERDOMAIN%\%USERNAME%”:(F) /t
  6. Now enter the following command to compress all files and folders within WinSxS. Note that this will only compress the ones that are not in use by any other programs or processes:
    compact /s:”%WINDIR%\WinSxS” /c /a /i *
    This might take a few minutes to compress each file.
  7. Once the compression has been completed, we must now return ownership and permission to default. Enter the following commands one by one:
    icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t
    icacls "%WINDIR%" /restore "%WINDIR%\WinSxS_NTFS.acl"
  8. Enter the following commands to restart the services we had earlier shut down:
    sc config msiserver start= demand<br>sc config TrustedInstaller start= demand

You may now check the size of the WinSxS folder and notice that it has shrunk significantly, by almost a third.
after compression

Closing words

The WinSxS file might be one of the most important ones in the system, but it’s also the biggest one, with an appetite for more storage space. However, no matter the amount of volume you allow for the system drive, it will become insufficient at one point.

Compressing or deleting unnecessary files and folders can aid a great deal in the available storage, especially when it can be performed safely, without harming the Windows environment.

If you liked this post, Share it on:
Subhan Zafar is an established IT professional with interests in Windows and Server infrastructure testing and research, and is currently working with Itechtics as a research consultant. He has studied Electrical Engineering and is also certified by Huawei (HCNA & HCNP Routing and Switching).

Leave the first comment

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information