Today I will show how to Cleanup you hard drives automatically with the Disk Cleanup tool. It will save your time and you can forget to run a Disk Cleanup manually. The Disk Cleanup deletes unnecessary files from your computer making space for new content. Let’s do this:
How to automate Disk Cleanup on your PC
- Run Command Prompt with Administrator Privilege.
- Type the following command and press Enter:
In this command, we’re using the switch /sagest:n to open the Disk Cleanup settings and at the same time create a registry key that will store the settings you choose. The n number, which is also stored in the registry, indicates the settings you want to use with the tool.
The number can be anything from 0 to 65535, and it’s basically like a filename that points to all the specific settings you want to use. This way, you can set different numbers to run the tool with different settings at different times.
- Once the Disk Cleanup Settings opens, check the items you want the tool to remove automatically from your system from the extensive list. Some of the files you can clean up include:
- Windows Update Cleanup
- Downloaded Program Files
- Temporary Internet Files
- Temporary files
- System error memory dump files
- Files discarded by Windows upgrade
- Windows ESD installation files
- Previous Windows installations
- Recycle Bin
- Temporary Windows installation files
- Click the OK button to save and store the settings in the registry.
- Open Start, do a search for Task Scheduler and click the result to open the utility.
- Right-click Task Scheduler Library, click New Folder and name the folder something descriptive like User Defined Tasks.
- Right-click the newly created folder and click Create Basic Task.
- Name the task, add a description you like, and click Next.
- Select when you want the task to run and click Next. These options are very flexible as you can set different times, in addition to set specific events to trigger the task. For the purpose of this guide, we’ll be choosing Weekly.
- Select the date and time, and click Next.
- On Action, select Start a program and click Next.
- Type the path to open the Disk Cleanup tool: C:\Windows\system32\cleanmgr.exe and include the argument /sagerun:11. (Remember to change the number 11 to the number you that you chose in step 2 to use the settings you have configured.)
- Click Next.
- On the Summary page, click Finish to complete the task.
After completing the task, the Disk Cleanup tool will run at the time you specified, deleting all unnecessary files from your computer. If for any reason, you need to change the current settings for the task, open the Task Scheduler, open the folder you created, double-click task, and update the configuration.