Disk Cleanup is a Windows utility that can delete many types of temporary files to help free up disk space on the hard drive. You might schedule Disk Cleanup to run automatically every week or month.
First, you’ll want to specify which items you want Disk Cleanup to delete each time it runs. The best way to do this is to run the utility via the Command Prompt. To open the Command Prompt in Windows 7, click the Start button, type cmd and hit Enter. In Windows 8 and later, open the Start screen, type cmd and open "Command Prompt" from the search results.
In the Command Prompt, type or paste the following command: cleanmgr.exe /sageset:1
You can click each item on the Disk Cleanup Settings for a description of what would be deleted.
You should see the Disk Cleanup Settings dialog box where you can choose the items you want the utility to clean up automatically. You’ll notice even more options than what you typically see in the menu. (Thanks, Command Prompt!) Once you hit OK the configuration will be saved.
Now you can create a Scheduled Task so the Disk Cleanup utility will run automatically using your saved configuration. In Windows 7 and prior, click the Start button, type task scheduler, and click on "Task Scheduler." In Windows 8 and later, open the Start screen, type task schedule and open "Schedule Tasks" from the search results.
On the Task Scheduler's Action toolbar menu, select Create Basic Task, and follow the wizard to set it up. When it asks for the task to perform select Start a Program. When it asks for the Program/script enter cleanmgr.exe, and then in the "Add arguments" field enter /sagerun:1
That's it!
Creating a Scheduled Task to run Disk Cleanup with your preferences.
Many PC geeks turn to the legendary CCleaner software to perform similar tasks, such as blowing away temporary files, cleaning the Windows Registry, erasing browser histories, and so on. You'll still need to use the Windows Task Scheduler to automate CCleaner, however.