You may be aware that the command-line version of the Disk Cleanup Utility in Windows offers many more clean-up options. Just earlier today, we saw how we could force Disk Cleanup Utility to delete ALL temporary files, including those temporary files created in the last 7 days.
Select the Triggers tab to edit the schedule period. Final thoughts. Both Disk Cleanup and Task Scheduler are built-in tools of Windows. These tools are available on all Windows versions, not just Windows 10. Combining them, you don’t need to use any tune-up tool to clean up your disk.
In this tutorial, we will see how to activate some additional cleaning options and automate the cleanup operation, so that you don’t need to run the Disk Cleanup Utility or Cleanmgr.exe in Windows 10/8/7 manually, every time. We will see how to use the Command line version of Disk Cleanup Tool or Cleanmgr.exe with more cleaning options. Use Task Scheduler to run it automatically using sageset, sagerun arguments.
Command-line version of Disk Cleanup Utility or Cleanmgr.exe
To begin, open an elevated command prompt, type cleanmgr /sageset:n, where n can be any integer between 1 and 255.
This switch /sageset displays the Disk Cleanup Settings dialog box and creates a registry key to store the settings. The number denotes the settings which will be stored in the Registry when your run sagerun switch later on – and basically lets you make shortcuts to different stored configurations or schedule automatic cleanup in the Task Scheduler.
In effect the /sagerun:n switch will run the specified tasks that are assigned to the n value by using the /sageset switch.
Lets begin with cleanmgr /sageset:1. This will open the Command Line version of Disk Cleanup Utility offering many more cleanup options.
If you have noticed, these are the options available in Cleanmgr.exe when you run it manually.
When you open it using sageset, as mentioned above, you will see the following clean up options. The options offered may vary depending on your system, however.
You may be surprised to see so many options being available and wonder why Microsoft chose not to make accessing them easier!
The options being offered may include:
- Temporary setup files
- Downloaded program files
- Temporary internet files
- Offline web pages
- BranchCache
- Debug dump files
- Old chkdsk files
- Previous Windows installations
- Recycle bin
- Update package backup files
- Setup log files
- System error memory dump files
- Temporary files
- Windows Update Cleanup
- Files discarded by Windows upgrade
- User file history
- Windows Defender
- Per user archived Windows error reporting files
- Per-user queued Windows error reporting files
- System archived Windows error reporting files
- System queued Windows error reporting files
- Windows ESD installation files
- Windows upgrade log files
- Zune temporary converted files.
Select the ones you want and click OK to save them. After you click OK, the settings (selection) will be stored in the Registry for future use. When you schedule it using cleanmgr /sagerun:1 to run through the Task Scheduler, it will take these settings for Disk Cleanup.
If you want to run this “Enhanced” Disk Cleanup Utility right away, type cleanmgr /sagerun:1 in the cmd window and hit Enter. Alternatively, you could type C:Windowssystem32cleanmgr.exe /sagerun:1 in a Run window and hit Enter. The disk cleanup operation will start right away.
TIP: To start the Disk Cleanup Tool with all the options pre-selected, use the /lowdisk switch. That is, open Run box and type the following and hit Enter: cleanmgr /lowdisk
Schedule and Automate running of Disk Cleanup Utility
If you would like to schedule Disk Cleanup Utility to run automatically, every once in a while, you can do so using the Task Scheduler. To do so, open Task Scheduler from the Control Panel. This post on How to Schedule a Task in Windows will give you more details about it. Click on Create Basic Task. Give it a name and description.
Select the Trigger; in this case the frequency. Click Next.
Since we have selected Monthly, fill in the other required details, and click Next.
As Action, select Start a program and click Next.
Since we want to run the Disk Cleanup Utility, write C:Windowssystem32cleanmgr.exe and Add argument as /sagerun:1. As we have saved the disk cleanup setting using the number ‘1’, we are using the same number ‘1’ here. Click Next.
Check the Summary. Select the Open Properties box and click Finish.
The Monthly Disk Cleanup Properties box will open where you will get to see details like Triggers, History, General Settings, Actions, and Conditions.
That’s it!
The Disk Cleanup Utility – with the additional options set – will run every month to keep your disk clean.
Related Posts:
Disk Cleanup is a maintenance tool that has been part of Windows for a long time, and it allows you to reclaim hard drive space to make room for more of your valuable content. With it you can quickly find and get rid of temporary and system files, such as previous Windows installation files and updates, which otherwise would be nearly impossible for regular users to find and remove — and those files might be taking up gigabytes worth of space!
However, even on Windows 10, Disk Cleanup remains a tool that you have to run manually. What you probably may not know is that you can configure the tool to run automatically to delete certain files from your computer.
In this Windows 10 guide, we'll walk you through the process to configure the Disk Cleanup tool and use the Task Scheduler to remove unnecessary files from your computer making space for new content.
How to automate Disk Cleanup on your PC
- Use the Windows key + X keyboard shortcut to open the Power User menu and select Command Prompt (Admin).
Type the following command and press Enter:
cleanmgr /sageset:11
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 Monthly.
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:Windowssystem32cleanmgr.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.
How to run Disk Cleanup out of its schedule
You can use the following steps, in the case, you want to run Disk Cleanup before the specified schedule:
- Use the Windows key + X keyboard shortcut to open the Power User menu and select Command Prompt (Admin).
Type the following command and press Enter:
C:Windowssystem32cleanmgr.exe /sagerun:11
Remember to change 11 to the number you have chosen. After running the command, the Disk Cleanup tool will open and run immediately, removing all the files you have configured on the tool.
How to modify Disk Cleanup settings
If you want to add or remove items you want Disk Cleanup to delete automatically, then use these steps:
- Use the Windows key + X keyboard shortcut to open the Power User menu and select Command Prompt (Admin).
Type the following command and press Enter:
cleanmgr /sageset:11
Remember to change 11 to the number you have chosen to store the settings.
- As you execute the previous command, you will notice that the Disk Cleanup tool will open with all the settings you have previously configured. Now simply modify the list by checking the new items and removing the ones you don't want.
- Click OK to complete the task.
Disk Cleanup is a great tool that continues to come included with Windows 10, and it can help you to reclaim space on your hard drive. In the latest version of the operating system, it's also a great way for users in the Windows Insider Program to check periodically and delete previous installations of the operating system, which are known to take up several gigabytes after a new build of Windows 10 is installed.
Schedule Disk Cleanup Windows 10 Mac
Important: Deleting previous installation files will prevent you from rolling back to the previous version of the operating system.
Furthermore, you can also use this technique to help family and friends to keep their computers free of clutter by automating Disk Cleanup to remove unnecessary files, such as those in the Recycle Bin, common temporary files, old Windows updates, and other files.
Finally, remember that even though we're focusing these steps for Windows 10 PCs, you can also use the same concept to clean up files and reclaim space on Windows 8.1, Windows 7, and other versions of the operating system.
Do you usually remember to clean up unnecessary files from your Windows 10 PC? What kind of utility do you use? Tell us in the comments below.
More Windows 10 resources
Where Is Disk Cleanup Located
For more help articles, coverage, and answers on Windows 10, you can visit the following resources: