With the disk capacities available in today's desktops, you probably have few if any hassles with clients that have run low on disk space. Without such hassles, it's easy to forget about disk cleanup and other general maintenance tasks necessary to keep Windows XP and Windows 2000 Professional clients running smoothly and efficiently.
Disk fragmentation and superfluous temporary files can have a detrimental impact on users' systems. XP and Win2K Pro include the Disk Cleanup and Disk Defragmenter tools, but getting users to run those tools is typically an exercise in futility. And if your IT staff is running as thin as most are these days, you probably won't get many volunteers to run these tools for users. In XP, you can automate both Disk Cleanup and Disk Defragmenter and use the built-in task scheduler (i.e., Scheduled Tasks) to run cleanup and defragment operations regularly. In Win2K Pro, you can automate Disk Cleanup but not Win2K Pro's Microsoft Management Console (MMC)-based Disk Defragmenter.
Because deleting unused files before defragmenting a disk is common sense and the best practice, I show you how to automate the Disk Cleanup tool first. Before I begin, though, I should mention that the potential for data destruction exists when you perform a defragmentation. If you don't feel secure in automating the defragmentation process for your clients, you're better off performing the task manually for them.
Disk Cleanup
To clean up unnecessary files in XP and Win2K Pro, you can use Disk Cleanup. You've probably used this tool through its GUI, but you can also run the tool from the command line. You can use command-line parameters (aka switches) to tell Disk Cleanup to delete certain types of files. At first, the command-line process might seem overly complex, but after you get past the learning curve, it makes sense.
When you run Disk Cleanup from the command line, you use the Cleanmgr command, which has three parameters: /d, /sageset, and /sagerun. Using Cleanmgr to automate file cleanup is a two-step process. First, you run the command with the /d and /sageset parameters to specify a set of files to delete, then you run the command again with the /sagerun parameter to perform the actual cleanup.
The /d parameter lets you select the drive on which you want to delete unnecessary files. The /sageset parameter lets you select the types of files you want to delete (e.g., temporary setup files, old Chkdsk files) and associate that set of file types with a unique number. You use the /d parameter with the /sageset parameter, following the syntax
cleanmgr /d X: /sageset:n
where X is the letter of the target drive and n is a unique numeric value from 0 to 65535. Disk Cleanup stores the set of files and its associated number in the registry.
You use the /sagerun parameter to run Disk Cleanup against the set of files you specified with the /sageset parameter. You use the syntax
cleanmgr /sagerun:n
where n is the number representing the set of files you want to delete. The /d parameter doesn't apply when you use the /sagerun parameter.
Let's try setting a group of files to delete, then run Disk Cleanup against those files. Open a command-shell window. Type
cleanmgr /d C: /sageset:100
and press Enter. Figure 1 shows the Disk Cleanup Settings dialog box that appears. In this dialog box, select the types of files you want to delete. When you click OK, Disk Cleanup will save this group of files as set number 100 in the registry. Now type
cleanmgr /sagerun:100
to automatically run the Disk Cleanup tool against those files. As you can see, this process is pretty simple.
File and Frequency Options
Depending on your user environment, you might want to perform light-duty cleanups on a frequent schedule or schedule more intense cleanups at less frequent intervals. As you consider the types of files you can specify for cleanup, you'll probably identify a few general classifications. My personal classification terms for the file-deletion groups are temporary files, operational files, and discretionary user files.
Temporary files. Temporary setup files, temporary Internet files, Windows temporary files, and temporary offline files all fall into the temporary files group. You're safe deleting the files in this group without hesitation.
Operational files. Old Chkdsk files and catalog files for the content indexer fall into the operational files group. These files are also safe to delete.
Discretionary user files. Downloaded program files, files in the Recycle Bin, and offline files fall into the discretionary user files group. Depending on your environment, these files might be off limits for an automated deletion scheme. Downloaded program files, which are in the %systemroot%\Downloaded Program Files folder, are typically ActiveX controls and Java applets that the browser downloads when you browse a site that uses them. No real harm occurs when you delete these items because the browser can download them again. However, you must consider frequency of use and the size of the controls or applets before deleting them.
Different users have varying approaches to using the Recycle Bin. Some users are barely aware of its existence, whereas other users access it daily as if it were a typical file-system folder. Because of the latter group of users, you need to be aware of your users' Recycle Bin habits before you automate the deletion of its contents.
The offline files store contains copies of network files that have been made available offline either manually by the user or through a Group Policy setting. Unless you have a problem with users creating excessive offline resources without merit, you should leave these files alone.
After you understand the ramifications of the available file selections, you need to decide how frequently you want to carry out certain deletion operations. For example, like many organizations, you might find that deleting temporary files once a week is adequate but deleting discretionary files once a week is overkill. If you need to perform certain deletions more frequently than others, you have to create multiple selection sets, providing a unique number to each with the /sageset parameter. Keep track of the numbers and their associated settings because no simple way exists to recall that information.
Mark June 03, 2004