Microsoft has for some reason left Disk Cleanup utility as a Desktop Experience component in the previous Windows Server 20xx editions which has made quite a few of us sad, me included. Made a quick script to make my life quite a lot easier as the files are available but not just in the right place. This simple fix will copy the disk cleanup required files to the correct location. There’s no need to install the Desktop Experience package to the server, there are no required DLL’s included or any registry edits.
Windows Server 2012R2 doesn’t work at the moment due to incompatibility with 16-bit applications. “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”
Serverfault discussion of the error here.
Currently supported Operating Systems:
- Windows Server 2008 x86
- Windows Server 2008 x64
- Windows Server 2008 R2
- Windows Server 2012
Windows_Server_Copy_Disk_Cleanup
Note: If you are unsure of the code, just open the batch file in notepad.
Microsoft KB 2852386 is required if the script doesn’t work.
What’s New
v1.1
– Cleaning of code
– W2012 Fix
– Mixed printout messages
Thank you!
Thanks for that – saved me some time!
You’re welcome!
Hi there – any chance of a version for SBS 2011?
At the moment I don’t have access to SBS2011, if you can provide me with the locations I will add them to the script.
Cheers for the script.
Unfortunately, this does not seem to work yet for 2012R2.
When I found the proper locations for the mui and exe, added these to the script, ran the script succesfully but then the error appears that “these versions are not supported”.
Even when copying the exe and mui from my 2012R2 terminal server with Desktop Experience installed, where disk cleanup works fine, Disk Cleanup runs but does not find any “old windows installations (windows.old)” or windows updates cleanup.
Bummer!
ps: you made a minor mistake in echoing the “copying mui” while copying the exe and vice versa ;)
I will update the script with W2012R2 soon :)
C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.3.9600.16384_en-us_4e94cff86c9dcc30
C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.3.9600.16384_none_5e02966c3182d7a7
Thank you for this, I will update this script as soon as possible.
also on line 44 you have x86 where it should be amd64
C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.2.9200.16384_en-us_b6a01752226afbb3
can anyone confirm that there is no such thing as 32bit 2008r2 or 32bit 2012 or 2012r2? I havent seen anything but 64bit in these flavors.
There is no 32-bit edition of 2008R2 or newer, the last 32-bit server OS was Windows Server 2008.
Thank You, With this you have extend the life of me and my machine. Nice.
Super big thanks!
Thanks for the script.
I tried it on Server 2012 fully patched to date and it has a couple of problems
Firstly the echo commands are the wrong way round. Secondly the location of cleanmgr.exe.mui appears to have moved to
C:\Windows\WinSxS\x86_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.2.9200.16384_en-us_5a817bce6a0d8a7d\
Finally and this is the kicker for soe reason the additional functionality to clean the system areas such as WinSxS does not appear unless I have installed “Desktop Experience” Any hints?
Thank you for this, I’ve noticed some issues with this as mentioned and will try to fix them sometime soon.
The script now works correctly with 2012.
Huge thanks for this. I appreciate you spending your time scripting this out!
I just tested the script on W2012 R2, and it does not work
Like mentioned in the post itself, this doesn’t work with 2012 R2. It only works with previous versions of Windows Server.
Great script!
found this didn’t work with windows 2008r2 without installing KB2852386 first
Waav !! Tech Guru .. you rocks.
Hi,
I was halfway through writing the same script just now when I suddenly thought “I wonder if anyone else has done this?” and hey! Cool, that saves me a job.
Looking at the code though, there seems to be a logic issue in the case of the OS not being matched to the VER output. i believe you need an EXIT at the end of the :failed block to stop it cascading down into the server 2008 code (and also possibly remove the systeminfo check, that’s also cascading and doesn’t seem to be doing anything?)
Cheers.
I will give a try now on Sbs 2011
Hello, it does seems to erase some files on the app however the files on the winsxs folder remain without deletion, is there a safe way to remove them without affecting anything else?