- MAXIMUMpcguides Windows Vista - http://www.maximumpcguides.com -

Automate Windows Vista’s Disk Cleanup

Posted By Brent Trahan On 7.18.07 @ 11:05 am In All, Maintenance, Vista, Windows | No Comments

Introduction

An important part of maintaining your Windows Vista computer is routinely running a Disk Cleanup to remove the trash left behind by Windows and software on your hard drive.

Most people don’t think of or want to do things like running Disk Cleanup. This guide shows you how to setup Disk Cleanup to automatically clean your hard drive every week by using a scheduled task.

Automate Disk Cleanup

Set What to Clean Using Sageset

Before you can set disk cleanup to automatically clean your computer periodically you need to tell it what to clean when it performs a disk cleanup. Here’s how to setup disk cleanup to clean your computer based on saved settings.

  1. Open the command prompt by typing cmd in the search box in the Start Menu and then pressing enter.
  2. Type CLEANMGR /sageset:1 in the command prompt and then press enter.

    Using the /sageset:1 switch saves the settings you set in the registry as :1. Disk Cleanup will use these settings when it runs from a scheduled task.

  3. Check off the files you want disk cleanup to clean when you run disk cleanup automatically in the Disk Cleanup Settings window.

    [1] automate-disk-cleanup1.PNG

  4. Click OK when you’re finished.

Setup A Disk Cleanup Scheduled Task

Now that we’ve saved settings that tell disk cleanup what to clean we can create a scheduled task that automates disk cleanup.

  1. Open the Task Scheduler by typing task in the Start Menu’s search box and clicking on Task Scheduler in the search results.

    Note: If you don’t receive a UAC prompt when you open Task Scheduler close the Task Scheduler and open it again by right-clicking Task Scheduler and selecting Run as administrator. You also need to pay attention to part B of step 5.

  2. Let’s create a new folder on the left side of Task Scheduler called Disk Cleanup by expanding Task Scheduler Library, and Microsoft, and then right-click the Windows folder and select New folder. Type Disk Cleanup as the name of the new folder and click OK to save it.
  3. Expand the Windows folder and click on the new Disk Cleanup folder you just created.

    [2] automate-disk-cleanup2.PNG

  4. Let’s create a new scheduled task by right-clicking in the white space in the white box located at the top center or the Task Scheduler window and select Create new task.
  5. Give the new scheduled task a name by typing it in the Name box.

    [3] automate-disk-cleanup3.PNG

    • Part B – If your user account you’re logged in with doesn’t have administrative privileges you must run the Task Scheduler as administrator and follow the steps in part B for disk cleanup to work.
    • Click the Change User or Group button in the General tab of the Create Task window.
    • Click the Advanced button in the Select User or Group window.

      [4] automate-disk-cleanup4.PNG

    • Click Find Now and select the user you’re currently logged in with from the list of users and groups that show up.

      [5] automate-disk-cleanup5.PNG

    • Click OK in the Select User or Group windows so that you’re back in the General tab of the Create Task window.
  6. Now we need to tell it how often to run disk cleanup by clicking the Triggers tab and click the New button.
  7. In this example I’m choosing to run disk cleanup on a weekly basis. Check off Weekly, set a time and day of the week to run disk cleanup and click OK when you’re finished. Make sure the time you select task to run is a time when your computer is turned on and logged in.

    [6] automate-disk-cleanup6.PNG

  8. Now we need to tell the Task Scheduler what to do at the time we just scheduled. Click the Actions tab and click New.
  9. Make sure Action says Start a Program in the New Action window.
  10. Type C:\Windows\System32\cleanmgr.exe under Program/Script and /sagerun:1 next to add arguments. The /sagerun:1 argument loads the settings you saved earlier. Click OK when you’re finished.

    [7] automate-disk-cleanup7.PNG

  11. Next, click the Conditions tab and check off Wake computer to run this task just encase your computer is sleeping when it’s time to run disk cleanup.

    [8] automate-disk-cleanup8.PNG

  12. Finally, click the Settings tab and check off Run task as soon as possible after a scheduled start is missed encase your computer is turned off when it’s time to run disk cleanup.

    [9] automate-disk-cleanup9.PNG

  13. Click OK to save the new task.
  14. Test the new scheduled task you just created by right-clicking it in the Task Scheduler window and selecting Run.


Article printed from MAXIMUMpcguides Windows Vista: http://www.maximumpcguides.com

URL to article: http://www.maximumpcguides.com/automate-windows-vista%e2%80%99s-disk-cleanup/

URLs in this post:
[1] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup1.PNG
[2] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup2.PNG
[3] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup3.PNG
[4] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup4.PNG
[5] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup5.PNG
[6] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup6.PNG
[7] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup7.PNG
[8] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup8.PNG
[9] Image: http://www.maximumpcguides.com/wp-content/uploads/2007/07/automate-disk-cleanup9.PNG

Copyright 2006-2008 Brent Trahan. All rights reserved.

Microsoft Windows is a registered trademark of Microsoft Corporation. Microsoft Corporation in no way endorses or is affiliated with MAXIMUMpcguides.com. All other products mentioned are registered trademarks of their respective companies. MAXIMUMpcguides IS NOT RESPONSIBLE for any damage or data loss to your computer from using this web site. All information on MAXIMUMpcguides is provided on an AS IS basis with NO WARRANTIES.