Make Windows Run Disk Cleanup Automatically with Task Scheduler
Running Disk Cleanup regularly in Windows is an important part of keeping your system running smooth. Remembering to do it is the hard part. Here’s how to make it happen automatically.
Running Disk Cleanup regularly in Windows is an integral part of keeping your system running smoothly. Here’s how to create a Scheduled Task to run this maintenance utility automatically.
Note: This will work with Windows 8, Windows 7, Vista, and XP
We previously showed you how to run Disk Cleanup and how to clean temp files it misses. But remembering to run it regularly is the challenging part.
Set Windows to Run Disk Cleanup Automatically
First, some command line magic — click Start and type: cmd in the search box. Hit Enter.
At the command prompt, type: cleanmgr.exe /sageset:1 then hit Enter.
The Disk Cleanup Settings window opens. Click the files you want to have Disk Cleanup delete. Click OK and close out of the command prompt.
Create a Scheduled Task
To create the Scheduled Task, click Start and type: task scheduler into the search box. Hit Enter.
When Task Scheduler comes up, you need to create a new task. Click Action and click Create Basic Task.
The Create Basic Task Wizard starts. Type in a name for the task and description. Click Next.
On the Task Trigger screen, select how often you want to run it. Here I’m selecting Monthly.
Next, select the date and time each month you want the task to run.
Under Action select Start a Program.
In the Program/script field type: C:\Windows\system32\cleanmgr.exe
In the Add Arguments field type: /sagerun:1 and click Next.
You’ll get a summary of the task you just created. Click Finish.
Now Disk Cleanup will run monthly at the selected time automatically.
Nowadays, more music and video are streamed from the cloud via services like Spotify, MOG, or Amazon Instant Video. So, there’s less of a need to have gigabytes of media files stored.
Still, there’s plenty of people who still have extensive media collections on their computer hard drive. Even if the files aren’t ripped CDs or DVDs, there’s plenty of home videos and pictures that you might not trust to be saved on Google Drive or SkyDrive. I know I’m not too fond of cloud services to default to automatically save my pictures. It’s more important to have them on my local Windows system.
Even though you might have less to store, and hard drive space is easy to come by these days, running cleaning up your hard drive regularly is still vital for an overall healthy computer.
Taos
December 6, 2011 at 5:36 pm
Is there a way to run a job to delete all my cookies? Perhaps launch ccleaner (you talked about that recently) on a schedule?
Brian Burgess
December 6, 2011 at 10:07 pm
Most major browsers have the option to auto clear history and cookies when you exit it.
Here’s an older article that talks about clearing cache, history and cookies in Firefox.
https://www.groovypost.com/howto/firefox/complete-guide-clear-cache-history-cookies-firefox/
You could create a bat file to do it, or I’m sure a scheduled task — something to look into for an article! Good idea Taos.
Thanks for reading.
Chaitanya
January 12, 2012 at 10:38 pm
@Brian or anyone else Kindly please provide solution for below problems. Am using Windows 7.
1. When I type ‘task scheduler’ in search field and Enter.In task Scheduler window under Action tab – “Create Basic task is disabled”. It shows Connect to remote computer.
2. When I type ‘disk defragment’ in search field and Enter. It displays task scheduler service is not running.
3. When I type ‘perfmon /report’ it displays path not found.
Chris
April 20, 2012 at 1:26 pm
Which string to cleanup old restore points except last to add to Task Scheduler reply asap :-)
Chris
April 20, 2012 at 1:56 pm
How to run above from std User Account :-)
andy
September 13, 2012 at 4:52 am
thanks for this great bit of info :)
Clint
May 22, 2013 at 11:06 am
Is there a kind of default set of files to check off or not check off for deletion?
Hammerfest
June 24, 2021 at 3:02 pm
Sadly, cleanmgr.exe doesnt quit after its done, it will stay in as a process until restart
llothos
October 1, 2021 at 8:00 am
your instructions at the end are showing different screenshots from the instructions. You indicate to type sagrun:1 but then screenshot shows sageset:1
Brandon Abell
December 7, 2021 at 6:16 am
You have a critical typo. It’s sageset and sagerun, not sagrun. You may also want to add the drive letter (generally the C drive) as an argument in the task.
Steve Krause
December 7, 2021 at 9:48 pm
Heya Brandon — thanks for the FYI. Yeah – A nasty typo! We’ve updated the article.
Thank you!