Posted on February 23, 2017 · Posted in Windows Server 2008 R2, Windows Server 2012 R2

Disk Cleanup on Windows Server 2012 / 2008 Without Installing Desktop Experience

By default, in Windows Server 2008 / R2 and 2012 / R2 there is no Disk Cleanup (cleanmgr.exe) utility that allows to delete unused files and clean up the WinSxS folder and component store from the files of updates that are no longer required. To run it, first you have to install a separate server component Desktop Experience using either Server Manager or PowerShell (Install-WindowsFeature Desktop-Experience).

Tip. To use cleanmgr to delete deprecated updates on Windows 2008 R2 / Windows 7 SP1, install KB2852386.

Together with Desktop Experience, many other unnecessary components are installed on the server:

  • Windows Media Player
  • Desktop themes
  • AVI support for Windows
  • Windows SideShow
  • Windows Defender
  • Disk Cleanup
  • Sync Center
  • Audio recording
  • Character Map
  • Snipping Tool

Desktop Experience feature on Windows server 2012 R2

To run Disk Cleanup on Windows Server, you can use an easier method: just copy two files Cleanmgr.exe and Cleanmgr.exe.mui from WinSxS to system directory. You can see commands to copy these files in different Windows versions below.

Windows Server 2008 R2 x64

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32\

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui C:\Windows\System32\en-US\

Windows Server 2008 x64

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_c962d1e515e94269\cleanmgr.exe C:\Windows\System32\

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_b9f50b71510436f2\cleanmgr.exe.mui C:\Windows\System32\en-US\

Windows Server 2012 x64

copy C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.2.9200.16384_none_c60dddc5e750072a\cleanmgr.exe C:\Windows\System32\

copy C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.2.9200.16384_en-us_b6a01752226afbb3\cleanmgr.exe.mui C:\Windows\System32\en-US\

To start Disk Cleanup, run cleanmgr.exe command with the administrator privileges. copy cleanmgr.exe on windows server 2008 r2

Windows Server 2012 R2 x64

The method described below doesn’t work in Windows Server 2012 R2 due to the changes made by KB2821895 update. The matter is that after you install this update, compression is used to store the binary files of the components. When trying to run the copied cleanmgr.exe, the following error appears:

Unsupported 16-Bit Application

The Program or feature \??\C:\Windows\system32\cleanmgr.exe cannot start or run due to incompatibility with 64-bit version of windows

Unsupported 16-Bit Application  The Program or feature \??\C:\Windows\system32\cleanmgr.exe cannot start or run due to incompatibility with 64-bit version of windows

As a workaround, you can use this method:

  • Install Desktop Experience: Install-WindowsFeature Desktop-Experience
  • Restart your server
  • Copy the files %windir%\system32\cleanmgr.exe and %windir%\system32\en-US\cleanmgr.exe.mui to any directory (c:\temp)
  • Uninstal the feature: Uninstall-WindowsFeature Desktop-Experience
  • Restart
  • Copy the files cleanmgr.exe and cleanmgr.exe.mui to the directories mentioned above

Later both of the files can be copied to other servers or integrated into Win 2012 R2 virtual machine templates.

Tip. To delete the obsolete updates in Windows Server 2012 R2, it’s easier to use the following DISM command:
dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

Related Articles