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 (83 downloads)

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

Author: Marco

Gelernter Fachinformatiker für Systemintegration (2010) CCA für XenServer 5.0 (2009) CCA für XenApp 5.0 (2011) CCA für XenApp 6.5 (2013) CCAA für XenApp 6.5 (2013) CCA für XenDesktop 5 (2013) Dell Wyse ThinOS Select Techniker (2011) Igel Authorized Partner (2009-2014) Intensivkurs “Group Policy Administration” Windows 7, 8.x sowie Windows Server 2008-R2 / 2012-R2 bei NT Systems, Dipl.-Ing. T. Pham (2014) Zu Gast auf der E2EVC Virtualization Conference in Berlin (2015) Zu Gast auf der Citrix Technology Exchange in Berlin (2016) Citrix Certified Associate – Networking (CCA – N) (2016) Citrix Certified Professional – Networking (CCP – N) (2017)

Leave a Reply

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