Automate Disk Cleanup using Task Scheduler in Windows XP

Configure the tasks

Cleanmgr1.JPG (32463 bytes)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.

Using the Task Scheduler

schtask2.JPG (35834 bytes)   schtask3.JPG (26729 bytes)   schtask4.JPG (25547 bytes)

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

Related article

Alter the "LastAccess" value for cleaning the Temporary files using Disk Cleanup utility

Clear the Temporary Internet Files using the Windows XP Disk Cleanup utility