How to cleanup the Windows 7/8/win 2008 winsxs folder?

Winsxs cleanup – Are you wondering how to cleanup the Windows winsxs? The cleanup of the winsxs folder can clear at least 4gb of disk space on your windows machine. The following will remove/clean the backup files from installing service packs that are located at /windows/winsxs.

First of all to do a winsxs cleanup you need to go to the “command line”. To do so you need to go to the “start menu” and type “cmd” then start cmd.exe as administrator (right click it).

Then type the following line in cmd.exe (for Windows 7 / Windows 8 / Windows 2008 r2):

dism /online /cleanup-image /spsuperseded

Depending on your version of windows there’re different tools you can use to clean up the winsxs folder:
Windows Server 2003 : VSP1CLEAN.exe
Windows Server 2008 : COMPCLN.exe

note: After running these commands you wont be able to uninstall any service packs!
note 2: I only tested this on my Windows 7 machine and it worked great, it freed up over 4 GB of space! I have not tried it on Windows Servers, so run it at your own risk.
note 3: If you get an “Error 87″ message this indicates that the winsxs folder is already clean.

Winsxs cleanup information

What is the Winsxs folder?

Windows side-by-side

Microsoft made a lot of changes and enhancements in Windows Vista promising better security and usability. One of the thing previously not in prior Windows that they added is a folder called winsxs. It means Windows side-by-side. Nothing much is known about this folder but a lot of users are complaining that it keeps on growing bigger and bigger taking up to 15GB for some people. This winsxs system was then also ported into Windows 7 and Windows 8 which brings us to continue asking this question.

So what is the Winsxs folder?

Basically winsxs folder contain a lot of hard-links or junction points (as being called by Microsoft) to a lot of system files. It keeps a lot of different versions of systems files which probably is used for when rolling back drivers and so on. So these files are actually just linkage to other files in your windows system. I think there are also some real physical files there but all these are managed by Windows and never explained by Microsoft on the structure of this winsxs folder.

Why does winsxs folder keep on growing in size?

When you look at the properties of this folder, the file size listed is not really the physical space taken up due to them being links and not physical files.

Here is an example that someone did experiment on junction points. It explain well on how windows cannot report disk space usage as opposed to linux’s link system. This is the main reason which causes confusion about winsxs.

- Assuming there is this test D: drive with 1000MB disk space left.
- We create an empty folder called test123.
- Copy a file that is 100MB in size into folder test123.
- Check the space usage and we see 900MB space left. So far so good.

- Next we create 3 junction points in folder test123 that points to the 100MB file.
- So we have 4 files there with 1 is actually physical file of 100MB.
- However, when we check the disk space properties for folder test123, it report 400MB being used by this folder.
- Check free disk space and it is still around 900MB. For explanation sake, we ignore the small space used by each junction point for the pointer file.

So you see, when checking disk space used by junction point, windows port the file size of the physical file it is pointing to. This is essentially how junction point works in windows. Not very smart design by windows engineer.

Back to the winsxs folder. You now know why when you do drivers updates and windows updates, winsxs folder size keep growing and growing. But if you check you free disk space, the growth doesn’t tally.