Windows Server 2008 R2 – Update cleanup with cleanmgr.exe

After many years with with Windows Server 2008 R2, we received over 200 different Windows Updates. The c:\ partition grows year after year. Among other things, Windows Updates creates uninstall information for every installed update. So if you ever needed, you could revert a single update. There are systems where this is crucial, but there are also many Windows Servers, where we know that this will never be necessary. In this case, you have the ability to use cleanmgr.exe to remove the following things automatically:

  • Downloaded Program Files
  • Internet Cache Files
  • Offline Pages Files
  • Previous Installations
  • Recycle Bin
  • Service Pack Cleanup
  • Temporary Setup Files
  • Thumbnail Cache
  • Update Cleanup
  • Upgrade Discarded Files
  • Windows Upgrade Log Files

The trouble is, that these options are only available, if you install the Desktop Experience feature. And we all know that we don’t want that on each and every system.

But there is a solution, although it’s unsupported. This description, although thoroughly tested, is provided as-is, and I grant no warranty.

The trick is, to copy the needed files installed by Desktop Experience, to a Windows Server without Desktop experience. You can find the files here, without installing Desktop Experience:

  • C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe
  • C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui

The files then have to be copied over here:

  • %systemroot%\System32\cleanmgr.exe
  • %systemroot%\System32\de-DE\cleanmgr.exe.mui
  • %systemroot%\System32\en-US\cleanmgr.exe.mui

After that, it is possible to create predefined cleanup sets, called sageset, which you can later refer to. These settings are written into the registry. I created these settings once on a test server and use them since then. You can reuse them, if you would like to or recreate them for yourself.

After everything has been prepared accordingly, you can start an elevated command prompt end execute the sageset via sagerun:

This may take a while, often 1-2 hours. After the command has been successfully executed, the system needs a reboot. During this reboot the cleanup will continue, so don’t bother if it takes alot longer than normally. On my first 9 test servers this purged about 7 GB on each server!

The steps provided above require a few manuell performed configurations. And we all know, that automation is the key to solve this. At my company, we use PDQ Deploy to automate such tasks. Below is a screenshot of my selfmade Deploy Package and the XML file as download.

cleanmgr_2008_R2.xml (107 downloads)

I hope I could help a few people out there, and if you have any questions, please leave me a comment.

Author: Marco

Marco is an IT-System administrator and IT-Consultant with 10+ years experience. He is specialized in the delivery of virtual Apps and Desktops with Citrix solutions. In 2017 he has been awarded Citrix Technology Advocate by Citrix for his community work (#CTA). His second core area is availability & performance monitoring with Zabbix, a leading open-source solution. His employer is the German IT-Company ANAXCO which is developing a Transport Management Software (TMS) based on Microsoft Dynamics AX. More about Marco

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.