Disk Cleanup offers some cool command-line switches that are documented only in a pair of obscure Knowledge Base articles. Through the use of these switches, you can save your preferences and rerun the cleanup process automatically using those settings. To do so, you need to use the following switches with Cleanmgr.exe
Opens a dialog box that allows you to select Disk Cleanup options, creates a registry key that corresponds to the number you entered, and then saves your settings in that key. Enter a number from 0 through 65535 in place of n.
Retrieves the saved settings for the number you enter in place of n and then runs Disk Cleanup without requiring any interaction on your part.
To use these switches, follow these steps: 1.
Open a Command Prompt window and type the command cleanmgr /sageset:200
. (The number after the colon is completely arbitrary; you can choose any other number from 0 through 65535.) Note that you must supply credentials from a member of the Administrators group to begin this task.
In the Disk Cleanup Settings dialog box, choose the options you want to apply whenever you use these settings.
Click OK to save your changes in the registry.
Open Task Scheduler from Control Panel, and start the Create Basic Task wizard. Follow the wizard’s prompts to name the task, and schedule it to run at regular intervals. When prompted to select the program you want Windows to run, type cleanmgr.exe
in the Program/Script box and type /sagerun:200
in the Add Arguments box.
Repeat steps 1–4 for other Disk Cleanup options that you want to automate.