How to configure automatic Disk Cleanup in Windows 7

Step by step how to configure automatic Disk Cleanup in Windows 7 using Disk Manager and Task Scheduler.

Windows disk cleanup graph

Instead of remembering to run “Disk Cleanup” in your computer, would not be better an automatic process that will do it for us? That’s what we are going talk about; how to configure automatic “Disk Cleanup” using Cleanup Manager and Task Scheduler in Windows 7.

Really brief, Cleanup Manager was designed to help you to get rid of unnecessary files from your hard drive, freeing up space for more important data.

To create an automated Disk Cleanup process is pretty simple, just follow these steps:

First, we need to configure Cleanup Manager to delete all unnecessary files.

1. Click Start in the search box Search programs and files type cmd; in the search result under Programs title, right-click on CMD and select Run As Administrator.

How to run application as administrator

2. The Command Prompt window will open, then type cleanmgr /sageset:13 (the #13 could be any number from 0 to 65535) and hit Enter. 

Command Prompt Window

3. In Disk Cleanup Settings select from the list all file types you would like to delete and click OK, now these settings are saved in your computer registry (sageset:13).

Disk Cleanup Settings  

Second, with the Task scheduler we are going to configure how and when to execute Disk Cleanup with the settings you’ve chosen.

4. Repeat step 1 but now type task scheduler, in Programs Right Click Task Scheduler and select Run As Administrator.

5. Next, Right Click Task Scheduler Library select New Folder and name it My Tasks (this step is just to keep tasks organized).

New task folder

6. Right-click in the newly create folder My Tasks and select CREATE TASK.

7. Choose a name for the task, like: AutoCleanUP and go to the next tab Triggers.

Disk Cleanup general settings

8. In the Triggers tab click New, click on the Begin the Task: and choose how you’d like to execute the task and pick and configure the Settings section any way you like. For this scenario I am going to select On a Schedule.

Note: I would recommend scheduling a time that your computer is ON and you are logged in.

Next, in Advanced settings select Stop task if it runs longer than and choose 1 hour, and Click OK.

Disk Cleanup trigger settings

9. Go to “Actions” tab, click New, make sure that Start a program is selected in the Action.

In Program/script type C:\Windows\System32\cleanmgr.exe and in Add arguments (optional), type /sagerun:13 (remember that is the number that you’ve chosen earlier in step 3) with the sagerun we are calling the settings stored in sageset:13 that we already configured, and click OK. 

Disk Cleanup Action settings

10. Go to Conditions these options are self-explanatory so choose the ones that suit your needs and go to Settings tap.

11. In Settings just select Run task as soon as possible after a scheduled start is missed and If the task fails, restart every:, and leave the default 1 minute and 3 times, and click OK.

Disk Cleanup settings tab

12. Now that Cleanup manager and the Task scheduler are setup and configured, we should test the task to see if it is working. To test, select the task (Right Click on it), and selectRun, once you see the Disk Cleanup process window you will know that it is working.

Run Task 

Disk Cleanup working


We work, learn, and play with our computers, but how often we do some sort of maintenance?

This method shown today it is not a complete computer maintenance process but it is a big part of it, and the process is fairly easy it should not take more than 10-20 minutes to configure. Now you can keep using your computer without worrying about doing a Disk Cleanup because it is now automated.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 14 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and Email him at [email protected].