-->

Automate Enhanced Disk Cleanup Tool operation in Windows 10/8/7

Tutorials | Dec 3, 2017 | Master3395

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 can force Disk Cleanup Utility to delete ALL temporary files, including those temporary files created in the last 7 days.

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.

sageset-400x234

This switch /sageset displays the Disk Cleanup Settings dialog box and creates a registry key to store the settings. The number denote 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.

disk-clean-2

If you have noted, these are the options available in Cleanmgr.exe when you run it manually.

delete-options-1

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.

delete-options-2

You may be surprised to see so many options being available and wonder why Microsoft chose to not make accessing them easier!

The options being offered may include:

  • Temporary setup files
  • Downloaded program files
  • Temporary internet files
  • Offline webpages
  • BranchCache
  • Debug dump files
  • Old chkdsk files
  • Previous Windows installations
  • Recycle bin
  • Update package backup files
  • Setup log files
  • System error memnory 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 one’s 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:\Windows\system32\cleanmgr.exe /sagerun:1 in a Run window and hit Enter. The disk cleanup operation will start right away.

clean-operation

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.

task-scheduler-windows-8

Select the Trigger, in this case the frequency. Click Next.

task-trigger-2-400x323

Since we have selected Monthly, fill in the other required details and click Next.

period-3

As Action, select Start a program and click Next.

action-4-400x323

Since we want to run the Disk Cleanup Utility, write C:\Windows\system32\cleanmgr.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.

program-5-400x323

Check the Summary. Select the Open Properties box and click Finish.

summary-6-400x323

The Monthly Disk Cleanup Properties box will open where you will get to see details like Triggers, History, General Settings, Actions and Conditions.

properties-7-400x349

That’s it! The Disk Cleanup Utility – with the additional options set – will run every month to keep your disk clean.

Keywords: microsoft, windows, Windows 10/8/7, tutorial, help, tips, tricks, clean

Author: Master3395

Comments:

comments powered by Disqus

Sponsored Ads:

Sponsored Ads:

DMCA.com Protection Status