Search this site
Hosted by A2
Webheads love A2 Hosting because they do PHP5, MySQL5, PostgreSQL 8, cPanel, Ruby on Rails, and SSH/Shell.
I use them because I like dealing with responsive, friendly human beings.
Plans from $2.95/month.
About Ed
Read my bio here.
Want to get in touch?
Use the contact form.
I can't promise a personal reply, but I read every message I receive.

Windows 7 Inside Out now shipping!
Archives
Subscribe (e-mail)



Powered by FeedBlitz



Last week I explained how to schedule the Disk Cleanup utility to perform basic maintenance tasks. But the Disk Cleanup utility can be overkill, and in some cases you might not want it to run through all its options. How can you tell it you just want it to just clean out the Windows Temp folder? The answer is found in some amazingly useful command-line switches that most Windows users know nothing about. (They’re documented in Windows XP Inside Out and in Knowledge Base article 315246, How to Automate the Disk Cleanup Tool in Windows XP.)

To control how the cleanup process works, you need to first know the executable command for the Disk Cleanup utility, cleanmgr.exe. Then you need to learn to use the following switches to modify its behavior:

  • /D driveletter  Runs Disk Cleanup using the drive letter you specify in place of driveletter (for example, type cleanmgr /d c:, to apply the utility to drive C). (This option is ignored if you use the /Sagerun switch.)
  • /Sageset:n  Opens a dialog box that lets you select Disk Cleanup options, creates a registry key that corresponds to the number you entered (where n is an arbitrary number from 0 through 65535), and then saves your settings in that key.
  • /Sagerun:n  Retrieves the saved settings for the number you enter in place of n and then runs Disk Cleanup without requiring any interaction on your part.

To put all the pieces together, follow these steps:

  1. Click Start, Run (or open a Command Prompt window) and type the command cleanmgr /sageset:200. (This number is completely arbitrary; you can choose any number from 0 through 65535.)
  2. In the Disk Cleanup Settings dialog box, choose the options you want to apply whenever you use these settings. In this example, I’ve cleared all the check boxes except the one in front of Temporary files.

    Cleanmgr

  3. Click OK to save your changes in the registry.
  4. Create a shortcut that uses the command cleanmgr /sagerun:200. Save the shortcut in the Windows folder using a descriptive name – Clean Temp Files, for instance.
  5. Open Control Panel’s Scheduled Tasks folder and start the Add Scheduled Task Wizard. When prompted to select the program you want Windows to run, click Browse and select the shortcut you just created. Follow the wizard’s remaining prompts to schedule the command to run at regular intervals.
  6. Repeat steps 1–5 for other Disk Cleanup options you want to automate.

That’s it. As long as the Task Scheduler service is running, your cleanup chores will be handled automatically on the schedule you specified.

22 Responses to “Tip of the day: Customize Disk Cleanup tasks”

  • Hee Hong says:

    Hi, I’m very interested in the topic dicussing. I actually having a similar problem, where I wish to setup or should I say add another task in a scheduled tasks that I setup previously. And the scheduled task should be running on multiple task. I know this can be done on Control Panel|Scheduled Tasks|Add Scheduled Task, but I wish to do it using command prompt, but not very sure how to do it. I try to check at /? using command prompt, but wasn’t helping. Please anyone can tell me how to do this? Thank you. My OS is running on XP with password protected.

  • Roger says:

    I have been trying to locate a method on using the cleanmgr /sagerun:# command in a batch file It isn’t that I can’t do it using in on a single account that I am working from but rather doing it as the administrator and running it on the other accounts while in the administrator’s account. Can you help?

Sponsors
Sponsored links