Monday, November 30, 2009

Automate Disk Cleanup

Disk Cleanup (cleanmgr.exe) is a computer maintenance utility included in Microsoft Windows designed to free up disk space on a computers' hard drive. The utility first searches and analyzes the hard drive for files that are no longer of any use, and then removes the unnecessary files. There are a number of different file categories that Disk Cleanup targets when performing the initial disk analysis:

• Compression of old files
• Temporary Internet files
• Temporary Windows file
• Downloaded Program files
• Recycle Bin
• Removal of unused applications or optional Windows components
• Setup Log files
• Offline files



You can use command-line options to specify that Cleanmgr.exe cleans up certain files. You can then schedule the task to run at a specific time by using the Scheduled Tasks tool.

To start the Disk Cleanup tool, either run the Cleanmgr.exe command, or click Start, point to Programs, point to Accessories, point to System Tools, and then click Disk Cleanup.

Disk Cleanup supports the following command-line options:

• /d driveletter: - This option specifies the drive that you want Disk Cleanup to clean.
• /sageset: n - This 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.

• /sagerun: n - This option runs the specified tasks that are assigned to the n value if you use the \sageset option.

For example, in Scheduled Tasks, you could run the following command after you run the cleanmgr /sageset:11 command:

cleanmgr /sagerun:11

This command runs Disk Cleanup and includes the options that you specified with the cleanmgr /sageset:11 command.

No comments:

Post a Comment