|Learning About Computers and the Internet|
The Windows operating system tends to build up temporary files over time. Managing these files with the system tool Disk Cleanup is discussed.
Regular Windows system maintenance should include the removal of unnecessary temporary files that the system accumulates. This computer housekeeping task is discussed in general on another page but here I will detail how to use the tool called Disk Cleanup that is included with the Windows operating system.
Although it has some limitations discussed in another section below, Disk Cleanup may be sufficient for many home PC users to help keep their system clean. The tool can be accessed in several ways .It is listed in the Start-All Programs- Accessories-System Tools group. It can also be opened by right-clicking on a drive icon in My Computer, choosing "Properties" from the context menu, and clicking the button "Disk Cleanup" on the properties sheet. Perhaps the quickest way to open the accessory is to enter "cleanmgr.exe" into the Start-Run line. (Actually, just entering "cleanmgr' is normally sufficient.) If you have more than one disk volume or hard drive, you will be asked to select the volume that should be cleaned. The figure on the right shows the main interface. Various different folders which store temporary files are listed. Certain listings are standard for all systems while others may vary according to an individual setup. The standard list includes Downloaded Program Files,Temporary Internet Files, the Recycle Bin, and Temporary files. The item "Downloaded Program Files" has a name that confuses many PC users. It does not refer to downloaded software programs but is a folder that contains ActiveX and Java applets that are sometimes downloaded for temporary use by Internet sites.
Scripting Disk Cleanup
More experienced PC users may be interested in the scripting possibilities that are possible when Disk Cleanup is invoked directly with the command "cleanmgr.exe". There are some switches that can be used as shown in the table below.
Here are some possible ways to use the switches. To clean a specific drive F:, enter into Start-Run or a command prompt the command:
To create a Registry key with specific settings to be used in a subsequent operation of Disk Cleanup enter:
These commands can be used in scripts for manual or automated use. For some additional discussion see this Microsoft reference
Automating Disk Cleanup
Once options have been set up by creating one or more Registry keys, the Disk Cleanup utility can be scheduled to run at regular times. Many PC users may find that an automated procedure is a relatively painless way to do some housekeeping chores. Automation using Task Scheduler is described at this reference from Ramesh Srinivasan.
Limitations of Disk Cleanup
Systems with the file system NTFS often experience a long delay during disk cleanup because the default behavior is for Windows to check to see if it should apply file compression to old files. Systems may even stop responding. The solution is to edit the Registry as described in this Microsoft article. Open Regedit and delete this key:
Another quirk of Disk Cleanup is that it may leave a lot of temporary files untouched. It is designed to remove only files that are over a week old. Also, as mentioned above, it only cleans %TEMP% but other temp folders can be added as described in the next section. Also, a more thorough cleaning can be obtained by opening a Temp folder, selecting all files and sub-folders, and deleting. Note that any temporary files currently in use by the system will be locked and cannot be deleted. In fact, the presence of locked files will cause the process of deletion to stop. Additional methods of cleaning are discussed here.
Adding Features to Disk Cleanup
Other folders can be added to those that are cleaned up in the normal setup by doing a Registry edit. I think it is worthwhile to add the \Windows\Temp folder and I have posted a REG file that does this. It can be downloaded at this link.
Another change to be considered is to shorten the time from the default seven days that temp files are kept before they can be deleted. Again a Registry edit is required. To change the time files are kept in %TEMP%, go to the Registry key:
As always, do not edit the Registry unless you back it up first.
Disk cleanup in Windows Vista and Windows 7
The general features of Disk Cleanup are similar in Windows Vista and Windows 7 but some details are different. Using the tool in the newer operating systems is discussed on another page.
|<< Home page||©2002-2013 Victor Laurie||Home page >>|