New
#1
Automating Clean Manager.
I thought I would post this more for information than anything else. It deals with the running ofCleanMgr.exe
in anElevated CMD Prompt
allowing theHidden
cleanup options to become available.
I am about toClean Install
and then customise the OS. I decided to write a Batch Script that basically cleans up the OS after ALL the customisation so that it is in a tip top state ready forImaging
.
One of the options is runningCleanMgr
inAdvanced Mode
, which basically gives you ALL the clean up options available, as opposed to theBasic Mode
for example because I wanted ALL the boxesChecked
. The problem with this, is that it asks for confirmation before continuing by pressingOK
, which isNOT
ideal as I wanted it fully automated.
In another Batch Script, I use %ComSpec% /c cleanmgr.exe /sageset:65535 & cleanmgr.exe /sagerun:65535 which is fine, even though it involves me having to pressOK
, but for that particular scenario it is what I want.
NOTE:
- You can use
ANY
number between1
and65535
for/sageset:
, but youMUST
use theSAME
number for/sagerun:
in order to use thePreset
configuration created by/sageset:
.
Therefore, in order for this process to be automated, you first need to runcleanmgr.exe /sageset:65535
prior to including it in a Batch script. This creates a storedREG
entry [ EVERY checkbox has its OWN SubKey ] for thePresets
of ALL the selected checkboxes.
REG
file => HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches
Here is mine after runningcleanmgr.exe /sageset:65535
, but obviously yours could be different . . .
Now, all you need to use in the Batch Script iscleanmgr.exe /sagerun:65535
, and because ALL the checkboxes are alreadyPreset
, there isNO
prompt during processing.
Basically, once thePresets
are configured in theRegistry
, you just need to run thecleanmgr.exe /sagerun:65535
command.
Summary:
Oncecleanmgr.exe /sageset:65535
has been run andPreset
, you can just usecleanmgr.exe /sagerun:65535
in anElevated CMD Prompt
, in aBatch Script
, or in aShortcut
, obviously using theSAME
number that you used for/sageset:
.
WARNING:
THIS WILL ALSO AUTOMATICALLY CLEANUP ANY PARTITIONS ON INTERNAL & EXTERNAL DRIVES.
Additional Information:
> CleanMgr - docs.microsoft.com
> CleanMgr - ss64.com
I just thought that someone might find this useful if they wanted to automate this process.
![]()
Last edited by Paul Black; 24 Apr 2021 at 08:00.