How To Automate Disk Cleanup using Task Scheduler in Windows

Automate Disk Cleanup using Task Scheduler in Windows.Configure the tasks: WebTechGeek Support Tips. Windows Tech Support.

For Windows 7 & Vista

Scheduling Maintenance Tasks:

You can automate any routine task that you perform. To do this, you can use the Task Scheduler service to schedule the task to run automatically. Not only can you schedule tasks to run once or periodically, but you can also schedule them to run when the computer starts, when you log on, or when a specific event occurs.

Getting Started with Task Scheduling: You use the Task Scheduler to view and work with scheduled tasks. To access the Task Scheduler, click Start, Control Panel, System and Security, Administrative Tools, Schedule Tasks.

The scheduled tasks are stored in the Task Scheduler Library. Task Scheduler displays tasks created by you or other users when you select the Task Scheduler Library node in the left pane. Unlike earlier versions of Windows, Windows 7 makes extensive use of scheduled tasks. In the Task Scheduler Library, you’ll find system tasks under Microsoft\Windows and Microsoft\Windows Defender. Tasks under Microsoft\Windows handle many of the background housekeeping tasks on your computer. Tasks under Microsoft\Windows Defender are used to automate malware scans.

Tasks can have many properties associated with them, including:
• Triggers that specify the circumstances under which a task begins and ends
• Actions that define the action a task performs when it is started
• Conditions that qualify the conditions under which a task is started or stopped
• Settings that affect the behavior of the task

Based on these properties, you can use Task Manager to create two types of tasks: basic
tasks and advanced tasks. Basic tasks have only triggers and actions, and are meant to
help you quickly schedule a common task. Advanced tasks have triggers, actions, conditions,
and settings, and are meant to be used by advanced users or administrators.

Creating Basic Tasks
You can create a basic task by completing these steps:

1. Click Start¨Control Panel¨System and Security¨Administrative Tools¨Schedule

2. Click the Action menu and then select Create Basic Task. This starts the Create
Basic Task Wizard.

3. On the Create a Basic Task page, type a name and description of the task. Click

4. On the Task Trigger page, select a run schedule for the task. You can schedule
tasks to run periodically (daily, weekly, or monthly), or when a specific event occurs,
such as when the computer starts or when the taskfs user logs on. Click Next.
The next page you see depends on when the task is scheduled to run.

5. If youfve selected a daily running task, the Daily page appears. Configure the task using these fields and then click Next:

Use the Start options to set a start date and time.

Recur every
Allows you to run the task every day, every other day, or every nth day, beginning
with the start date you set. For example, if you want the task to run
every other day, youfd set the gRecur every X daysh text box to 2 days.


For Windows XP: Type cleanmgr /d c: /sageset:100 in the RUN box. The Disk Cleanup dialog box appears. Check the items you want to clean every time you run this process, for example Recycle Bin, Temporary Internet Files, Old Chkdsk files and then click on OK.

/d driveletter: – This switch selects the drive that you want Disk Cleanup to clean. Note that the /d switch is not used with /sagerun:n.

Create a new shortcut in your Windows folder using cleanmgr /sagerun:100 as the command line. Name it as CleanupTask.


How To – Using the Task Scheduler

* Open Scheduled Tasks from Start Menu, Accessories, System Tools. 
* Double-click on Add Scheduled Task 
* Choose Next 
* Click on Browse and locate the shortcut file that you just created [CleanupTask] 
* Choose Weekly and click Next 
* Select the Time and day during which you want the CleanupTask to run. 
* Click Next 
* Type-in the Username and password. [By default, task scheduler won’t run with blank password]
* Choose Next, Finish


NOTE: sageset:n – option displays the Disk Cleanup Settings dialog box and also creates a registry key to store the settings that you select. The n value, which is stored in the registry, allows you to specify tasks for Disk Cleanup to run. The n value can be any integer value from 0 to 65535. To have all of the options available when you use the /sageset option, you might need to specify the drive where Windows is installed.

You can have any number of tasks created [in Sageset 1, you can select “Recycle Bin”, in Sageset configuration 2, you can deselect Recycle-bin. Each of the Sageset configurations are stored in the following registry key and sub-keys:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \VolumeCaches