Search This Blog

Thursday, October 21, 2010

Command-Line Switches for Disk Cleanup and How to Automatic Disk Cleanup

 

Disk Cleanup offers some cool command-line switches that are documented only in a pair of obscure Knowledge Base articles. Through the use of these switches, you can save your preferences and rerun the cleanup process automatically using those settings. To do so, you need to use the following switches with Cleanmgr.exe:

image

/Sageset:n Opens a dialog box that allows you to select Disk Cleanup options, creates a registry key that corresponds to the number you entered, and then saves your settings in that key. Enter a number from 0 through 65535 in place of n.

/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 use these switches, follow these steps:

1. Open a Command Prompt window and type the command cleanmgr /sageset:200. (The number after the colon is completely arbitrary; you can choose any other number from 0 through 65535.) Note that you must supply credentials from a member of the Administrators group to begin this task.

image

2. In the Disk Cleanup Settings dialog box, choose the options you want to apply whenever you use these settings.

image

3. Click OK to save your changes in the registry.

Automatic Disk Cleanup:

1. Then go to Start under Search type in Task Scheduler

2. Start the Create Basic Task wizard.

image

3. Choose how often you want to run it

image

4. Then under Action select Start a Program

image

5. Under Program / Script type in  cleanmgr.exe and type /sagerun:200 in the Add Arguments box.

image

6. Then Click Next and Finish

Repeat steps 1–6 for other Disk Cleanup options that you want to automate.

No comments:

Post a Comment