Automating Disk Cleanup Tool in Windows 10

Is it possible to automate disk cleanup in Windows 10?
|

Hi,

To assist you with your concern on automating disk cleanup in Windows 10, you may do so using Task Scheduler. First, we need to activate some cleaning options and then use the Task Scheduler.

Using Command line version of Disk Cleanup Utility or Cleanmgr.exe

  1. Open an elevated command prompt, type cleanmgr /sageset:n, where n can be any integer between 1 and 255. Note: 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.
  2. Opening the Command line version of Disk Cleanup Utility offers more cleanup options. Select the ones that 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.
  3. 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.

 Here are the steps to schedule a task:

  1. Open Task Scheduler from the Control Panel or type Task Scheduler on the search box.
  2. Click on Create Basic Task. Give it a name and description.
  3. Select the Trigger, in this case the frequency. Click Next.
  4. Fill in the required details and click Next.
  5. As Action, select Start a program and click Next.
  6. 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.
  7. Check the Summary. Select the Open Properties box and click Finish.
  8. The Monthly Disk Cleanup Properties box will open where will you get to see details like Triggers, History, General, Settings, Actions and Conditions. 

Let us know how it goes.

 

51 people found this reply helpful

Was this reply helpful?

Yes
No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

How do i specify which items [e.g. recycle bin] are to be cleaned?

18 people found this reply helpful

Was this reply helpful?

Yes
No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I have the same question! I can't figure out how to specify which items to be cleaned. The automation works, but, for example, the recycle bin isn't emptied unless I manually do the disk cleanup and select the option.

20 people found this reply helpful

Was this reply helpful?

Yes
No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Also the Microsoft instructions on-line for deleting [or opening to amend] a task in Windows 10 are impossible to carry out.

11 people found this reply helpful

Was this reply helpful?

Yes
No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I figured it out! Under Christian Mart's original reply, they state:

Using Command line version of Disk Cleanup Utility or Cleanmgr.exe

  1. Open an elevated command prompt and type cleanmgr /sageset:n, where n can be any integer between 1 and 255.

"Elevated" meaning Administrator command prompt. If you try to enter sageset:n in the regular command prompt it doesn't save the settings, do the same thing with an Administrator command prompt and it saves!

 When opening command prompt, right click the program and select "Run as Administrator".

23 people found this reply helpful

Was this reply helpful?

Yes
No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 19, 2021 Views 21,537 Applies to: