Just tried to get cleanmgr installed and working on a fresh 2012 R2 install. Copies CleanMgr.exe & CleanMgr.exe.mui across like done before but when it is run get error: The Program or feature \?system32\cleanmgr.exe cannot start or run due to incompatibility with 64-bit version of windows
You need to enable Disk Cleanup by installing the
Desktop Experience
feature (see Enabling Disk Cleanup Utility in Windows Server 2012). The command line interface should still be available via theC:\Windows\CleanMgr.exe
executable.I got back to my lab and tried grabbing
CleanMgr.exe
andCleanMgr.exe.mui
from the x86 and WOW64 bit updates thinking that might fix the compatibility issue:And the results...
Ah. The march of progress. I see two options. You can get ProcMon running and try to track down all the various DLLs in the WOW64 subsystem (maybe by doing a
Desktop Experience
install on a throwaway server), you can try this method to remove thewindows.old
directories if that's what is ailing you or you can follow Microsoft's officially supported albeit misguided recommendations and install it from the Desktop-Experience Windows Feature.I had the same problem as Keith described for W2K12 R2 SP1 server. My solution for this problem:
I use this procedure for making vmware template machines, so i did this once and all other future w2k12r2 server will have the cleanmgr files already installed
Copying directly from the
c:\windows\WinSxS
directory, although once supported, now no longer works as-is. This appears to be a change within Windows Server 2012 R2 Update 1a quick view of the
cleanmgr.exe
binary in a hex editor reveals that theC:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.3.9600.17031_none_5e3588b0315d2219\cleanmgr.exe
file is no longer begins with the required magic header "MZ...", instead it starts with "DCN..." and the file is much smaller than the expanded version. This is why we are getting the "unsupported..." dialog box above.This appears to a direct result of KB 2821985 improvement #2 - Adds a feature that compresses unused binary files and allocates free disk space to prepare Windows for future updates.
Still trying to figure out how to extract/uncompress the files programmatically. :^(
I believe this is what you're looking for.
Comment by Nick was close to this, but this is a bit cleaner and uses $env rather than %env% variables (powershell likes $env better)
Someone has kindly provided a zip file containing the required files which unlike the steps above (not including installing the "desktop experience rubbish) actually works on Windows Server 2012 R2 64-bit.
You can read more from the author's page and get the download links yourself. It is a zip file that you expand onto your System drive and it puts the files where needed. There is also a link for the Windows 2008 version.
Quite why we have to go to such measures for such a simple thing as cleaning up the hard disk is a mystery to me.
UPDATE: I have opened a Windows Server user voice request here - if you think having disk clean-up installed is useful, please vote for it.
You can copy the Cleanmgr.exe and Cleanmgr.exe.mui from an updated Windows 8 to the server.