How to Schedule Disk Cleanup in Windows
This guide shows you how to schedule disk cleanup in Windows so the built-in Disk Cleanup tool runs automatically on a regular basis. You’ll set up a basic task in Task Scheduler that launches Cleanmgr with the right flags, and you’ll learn how to customize it to target specific drives or run as administrator. No extra software is needed—everything uses tools already in Windows.
What You’ll Need
- A Windows PC with administrative rights (you’ll need to create a scheduled task that runs with highest privileges).
- Knowledge of which drive you want to clean (usually C:).
- About 10 minutes of time.
Step-by-Step
- Open Task Scheduler. Press Win+R, type
taskschd.msc, and press Enter. Alternatively, search for “Task Scheduler” in the Start menu. - Create a new task. In the right-hand pane, click Create Basic Task…. The Basic Task Wizard opens.
- Name the task. Type a descriptive name like “Scheduled Disk Cleanup” and optionally a description. Click Next.
- Choose when to run. Select a trigger that fits your schedule—Daily, Weekly, Monthly, or One time. For most users, Weekly is a good balance. Click Next.
- Set the schedule details. Pick the start date and time, and for weekly, select the day(s). Click Next.
- Select the action. Choose Start a program and click Next.
- Enter the program and arguments. In the Program/script field, type
cleanmgr.exe. In the Add arguments (optional) field, type/sagerun:1(we’ll set up the settings in the next step). Click Next. - Finish the wizard. Review the summary and click Finish.
- Configure the cleanup options. Now you need to tell Disk Cleanup what to delete. Open a Command Prompt as administrator (search for “cmd”, right-click, and select “Run as administrator”).
- Run Disk Cleanup in setup mode. Type
cleanmgr /sageset:1and press Enter. This opens the Disk Cleanup dialog with all cleanup categories. Check the boxes for the items you want removed (e.g., Temporary files, Recycle Bin, Windows Update Cleanup). Click OK. Your selections are saved under the number 1. - Test the scheduled task. In Task Scheduler, find your task in the Active Tasks list, right-click it, and select Run. Disk Cleanup should start immediately. If it doesn’t, see the Troubleshooting section.
Common Mistakes
- Forgetting to run /sageset first. If you skip step 10, the scheduled task runs with no cleanup selections, so it does nothing.
- Not running as administrator. Some cleanup items (like Windows Update Cleanup) require admin rights. If the task runs without highest privileges, those items are skipped.
- Wrong drive letter. The /sageset and /sagerun commands operate on the system drive by default. To clean a different drive, you need to use the /d flag (e.g.,
/d D:) in both the setup and run commands. - Using /sagerun without a number. The number must match the one you used in /sageset. If you use /sageset:1, you must use /sagerun:1.
Tips
- Start with a manual run. Before scheduling, run
cleanmgr /sageset:1and thencleanmgr /sagerun:1manually to verify the settings work. - Schedule during idle time. Set the task to run at night or early morning when you’re not using the computer, to avoid performance dips.
- Use a weekly schedule. Daily is overkill for most systems; weekly keeps temporary files in check without wearing the disk.
- Combine with a disk defrag. If you have a traditional hard drive, you can add a second task to defrag after cleanup, but SSDs don’t need it.
- Monitor the results. After the task runs, check the Task Scheduler history (right-click task → Enable All Tasks History first) to see if it completed successfully.
Troubleshooting
Task runs but nothing is cleaned. This usually means the /sageset settings weren’t saved. Run cleanmgr /sageset:1 again and make sure you click OK. Also check that the task’s arguments are exactly /sagerun:1.
Task doesn’t start at all. Verify the task is enabled (right-click → Enable). Check the trigger settings—if you set a past start date, it won’t run. Also ensure the user account under which the task runs is still valid and has a password.
Disk Cleanup opens but closes immediately. This can happen if the cleanup takes a long time and you see it close normally—that’s fine. If it closes without doing anything, check the Event Viewer (Windows Logs → System) for errors from Task Scheduler or Cleanmgr.
“Access denied” error. The task needs to run with highest privileges. In Task Scheduler, right-click your task → Properties → check Run with highest privileges. Also make sure the user account has admin rights.
Cleanup runs but doesn’t free much space. The default selections are conservative. Run /sageset again and enable more categories, especially “Windows Update Cleanup” and “Temporary files”.
Frequently Asked Questions
Q: Can I schedule Disk Cleanup on Windows 10 and 11?
Yes, the steps are the same for both. The cleanmgr tool is still included in Windows 11.
Q: What does /sageset and /sagerun do?
/sageset opens the Disk Cleanup dialog and saves your selected options under a number (like 1). /sagerun runs Disk Cleanup using the options saved under that number. The number can be any integer from 1 to 65535.
Q: Is it safe to delete all items in Disk Cleanup?
Most items are safe, but be cautious with “Downloads” if you have files there you need. The tool only deletes files in system temp folders, not your personal documents.
Q: How often should I schedule Disk Cleanup?
Weekly is a good balance for most users. If you have a small SSD, you might want daily; if you rarely install software, monthly is fine.
Q: Can I schedule Disk Cleanup for a different drive?
Yes, use the /d flag. For example, to clean drive D:, run cleanmgr /sageset:1 /d D: to configure, and cleanmgr /sagerun:1 /d D: in the task.
Q: Will scheduled Disk Cleanup affect my open files?
No, Disk Cleanup only deletes files that are not in use. If a file is locked by a program, it will be skipped.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.