Running Disk Cleanup in batch is a 2 part process. During the first phase, you interactively select the items you wish to cleanup and name
(number) the cleanup. During phase 2, you run or schedule the cleanup number.
To run phase 1:
Cleanmgr.exe /dC: /sageset:n
where:
C: is the drive letter. If the drive letter is the boot drive, all options are available, otherwise, only the Recycle Bin and Content Index Catalog is available.
n is the identifying cleanup number, from 0 - 65535.
You interactively select options from the following list:
Temporary Setup Files Downloaded Program Files (%SystemRoot%\Downloaded) Temporary Internet Files Old Chkdsk Files Recycle Bin Temporary Files (%Temp%) Temporary Offline Files Compress Old Files - This will compress files that have not be used in a while. Catalog Files for the Content Indexer (Old)Once you number the cleanup and select the options, you can run or schedule the cleanup. Example:
Cleanmgr.exe /dC: /sageset:1 - to specify drive C: and select cleanup options, which you identify as 1.
Cleanmgr.exe /sagerun:1 - run or schedule the above cleanup.
NOTE: The results of your selection are stored, by cleanup number, in the registry.