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
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 the windows.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.
a quick view of the cleanmgr.exe binary in a hex editor reveals that the C:\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.
You can source these files from other servers (preferably running the same version of Windows Server), or you can snag the files from the WinSXS folder on a valid Windows install. An example of the WinSXS paths can be found below:
The built-in Windows tool, Disk Cleanup, which can be launched as cleanmgr.exe from the Run dialog, supports a number of interesting command line arguments which can be useful in various situations. Let's review them and see how you can use them.
cleanmgr.exe /SAGESET
The SAGESET key allows you to create a preset of selected checkboxes in cleanmgr.exe. Once this is done, you can launch the preset using the /SAGERUN option. The syntax is as follows:
Since you started cleanmgr.exe /SAGESET:n elevated, it will be opened directly in the "Clean up system files" mode. See the following article: How to run Disk Cleanup directly in the system files mode and speed it up.
cleanmgr.exe /TUNEUP
The command is similar to the described SAGESET functionality. In Windows 10, it does exactly the same thing. Like the SAGESET switch, it writes presets to the Registry. It can be used instead of SAGESET. The syntax is as follows:
cleanmgr.exe /LOWDISK
This switch is used when Windows notifies the user that he is running out of disk space on a drive. When you click the notification, Disk Cleanup opens with all checkboxes checked by default. You can execute it from the Run dialog as follows:
cleanmgr.exe /VERYLOWDISK
It is the same as the /LOWDISK disk switch, but it will cleanup all files automatically. It won't show you a confirmation, but will show you a dialog to indicate how much free disk space you have now.
Syntax:
cleanmgr.exe /SETUP
The setup switch analyzes the system files left from a previous Windows version. For example, if you upgraded from Windows 7 to Windows 10, running this switch is useful. It also needs to be executed from an elevated command prompt:
C drive low disk space is common issue in Windows Server 2012 and R2. To solve this problem, firstly you'd better free up disk space. To accomplish this task, Windows Server 2012 has native Disk Cleanup tool. But different with other version, this tool is not enabled by default. This is the reason why many people feedback that Disk Cleanup is missing in Windows Server 2012 (r2). In this article I'll introduce how to add, install, enable Disk Cleanup in Windows Server 2012 R2, and how to run Server 2012 Disk Cleanup (cleanmgr.exe) to free up disk space.
The same with other versions, Windows Server 2012 system C: drive is getting full after running the server for a period of time. One of the solution is cleaning up C drive, delete unnecessary and junk files to reclaim disk space. To do this, Microsoft provides native Disk Cleanup utility, which can be run via cleanmgr command or with GUI wizard.
To clean up C drive in Server 2012 (R2), the native Disk Cleanup utility is the first choice, because it is easy, fast and able to delete most common types of junk files safely. There are third party optimization programs, but the native cleanup utility is safe and powerful enough. There's no need to fight for 1GB more free space but put server in danger.
It is easy and fast by copying files to specific folder, but in some environment Disk Cleanup doesn't work. By installing Desktop Experience feature, Disk Cleanup is fully functional, but it requires reboot to complete installing. Furthermore, many other unnecessary components will be installed on the server together with Desktop Experience, such as:
My test server is new installed, so I can reclaim little space. To the servers that never or have not free up disk space for a long time, Server 2012 Disk Cleanup utility may helps you regain several GBs of disk space.
With server partition software, you can shrink any data volume on the same disk to get Unallocated space and then add into C drive. In this way, there will be more free space in C drive. Operating System, programs and anything else keep the same with before. This step is most important to help solve this problem.
760c119bf3