How to Setup Auto Disk Cleanup in Windows Server 2012

Since we have added the disk cleanup utility in our previous article now we will learn that how we can schedule a disk cleanup task in windows server so that we can keep our windows server performance optimized without our manual interruption and assistance.

We will use Windows Server 2012 R2 as an example, Log into your Windows server and open “Run” by right-clicking on the Windows icon.

Once Run bar is opened write the mentioned command and hit enter “cleanmgr.exe /sageset:1”. You can choose any number between 1 and 65535 but I have chosen 1.

It will open up “Disk Cleanup Settings”.

From here we can select the different files which we want to delete through disk cleanup utility. Once files are selected press “Ok”. Disk cleanup setting wizard will be closed so now we will open “Task Scheduler”.

Task Scheduler can be opened by clicking on the start button and select the control panel. In control panel click on administrative tools and scroll down to select Task Scheduler.

Double click on it and it will open Task Scheduler wizard. On the right side under “Actions” tab there is an option of “Create Task”.

Click on create task and name the task accordingly. I have names it “disk cleanup” and you can select different other options as well.

Click on “Triggers” tab and click on “New” as it will open “New Trigger” wizard

Here you can choose the settings accordingly and once you are done with the settings of new trigger click on “Actions” tab.

Click on “New” as it will open up the “New Action” wizard and click on browse tab under “Program/Script”. Scroll down to select the “Disk Cleanup”.

Now we will add arguments value as “/sagerun:1” so that it can run with our previously allocated settings for the condition 1.

Press “Ok” and it will bring you back to the create task wizard click “Ok”.

It will ask for the administrative password and you can check that newly created task is present in “Active tasks” portion of task scheduler.

Muhammad Imran Habib

Imran is a technology evangelist with 8 years of experience working with some of the Industry leading companies. Imran's expertise includes On-Prem/Virtual Infrastructure deployments, IT Solutions for SMEs, End User Computing Support.

You may also like...

1 Response

  1. Donovan says:

    Cool trick thank you!