Windows Disk Cleanup utility is a great tool for cleaning up multiple locations on your Vista or XP Computers. The one drawback to the utility is that you need to configure it every time you want to cleanup your disk drives.
Instead, you can easily pre-configure specific tasks for Disk Cleanup to use and create a shortcut on the Desktop to run it at any time.
In order to create a customize configuration for Disk Cleanup, we need to run the utility using the sageset option. This option allows you to configure the Cleanup utility, and save it, so we can run it later with the custom configuration.
To get started, open the Run window by clicking on Start \ Run… and type:
cleanmgr.exe /d c: /sageset:1
Where:
cleanmgr.exe = executable for Disk Cleanup utility.
/d c: = is the drive letter we want to use, and since it contains the Windows installation, will have all available options. (NOTE: see more information below about multiple drives)
/sageset:1 = used to create the registry key for storing the configuration.
NOTE: Following screen shots are from Vista Disk Cleanup Utility. XP cleanup will look similar but with less options.
Now make any selections by checking each item you want to cleanup. When finished, click OK.
Next, go to your Desktop, right click and select New \ Shortcut. Then enter the following command in the "Type the location of the item:"
cleanmgr /sagerun:1
Click next and give the shortcut a name, such as "Quick Clean Up" (do not use quotes). Now when you want to run the customized configuration for Disk Cleanup, you can just double click on the shortcut.
If you are wondering, the /sagerun:1 option tells Disk Cleanup which configuration to use. So that means you can create different configurations (such as cleanup the trash, or cleanup temp and setup log files) by specifying the number with the /sagerun variable.
But I Have Multiple Drives?
Unfortunantly, when Disk Cleanup runs, all drives are cleaned (regardless of the number of drives you have) with each run. While you cannot choose which drive to clean, specifing the drive letter when creating a configuration allows you to choose only the options that are available on that drive.
For example, if you have an E:\ drive, use:
cleanmgr.exe /d E: /sageset:2
and configure the tasks for Disk Cleanup to use on the E:\ drive. Options that only pertain to that drive should only be available.
Even though the custom configuration will also clean the same selections on the C:\ drive, you can tailor the configuration to only what is available on the E:\ without just selecting everything.
When finished, you can either create another shortcut on your Desktop using the following command:
cleanmgr /sagerun:2
Or create one shortcut to run both cleanup tasks which will basically combine the selections into one automatic cleanup.
cleanmgr /sagerun:1 /sagerun:2
Now you can cleanup your Computer with custom configurations set to your preferences automatically.
Comments on Create Customize Shortcut For Running Windows Disk Cleanup
Cor'e =) @ 8:19 pm
I did this, but i got very buggy results:
Two Runs:
cleanmgr /d c: /sageset:1
cleanmgr /d g: /sageset:2
and
Created Two Shortcuts:
%windir%\system32\cleanmgr.exe /sagerun:1
%windir%\system32\cleanmgr.exe /sagerun:2
Now running either shortcut actually runs CleanUp for BOTH(!) Drives C: & G: rather than just the single drive letter alone!
What's Up??? Does not work as advertised.
@Cor'e =)
MAN! What was I thinking when I wrote that tip (big time goof-up). The only bug you found was my mistake. Here's the deal:
Disk Cleanup CANNOT be run against a specific drive. As you correctly pointed out, when it runs, all drives are cleaned. The reason for selecting a drive, when setting up a cleanup, is that it will only show options available for that drive, instead of all available options when using the drive where Windows is installed.
So, even though Disk Cleanup will still run against all drives, it's optimized for that particular drive based on the selections you made.
I have edited the article and removed the section about running against a single drive.
Keep uP the good work!
Lipjam @ 3:50 am
I scheduled a disk cleanup on Server 2k and expected it to be done overnight but when I got in the next morning I was met with a dialog box asking me to select the drive I wished to clean? I thought this program just cleaned all drives. What's the story?
@Lipjam
Did you run a test using the same command before scheduling it to run overnight? If not, run a test and see why it's prompting you to select a drive.
woodsman @ 10:12 pm
this is stupid only and idiot would do this this is completely unnecessary
simply open start menu go to search box type in disk cleanup
when the file comes up in your search you right click on it and click create shortcut and bam you are done
THIS PERSON WHO POSTED ABOVE INSTRUCTIONS IS AND IDIOT AND MAKING THIS HARDER THAN IT NEEDS TO BE PLEASE KEEP IT SIMPLE
@woodsman
Hate to break the news to you buddy, but you completely missed the boat on this one. It's about customizing the settings…but since your so intelligent I'm sure I don't need hand puppets to explain it to you.
Barisal @ 12:50 pm
Thanks for this very useful topic. I've found what the exact thing (custom setting) which I couldn't find in Microsoft's page.
Alan Grill @ 8:43 am
I did find this helpful but it isn't quite working. It did not clean out either the c:\tmp or c:\windows\tmp folders. I am not sure about the Temporary Internet files.