With Windows XP, scheduling a disk defragmentation process from the command line is built into the operating system, ensuring that you can keep your users’ desktops running smoothly and efficiently.

What? You’re not running Windows XP on your desktops yet? Are you out of luck? Nope! An open source program from MorphaSys called AutoDeFrag can allow you to do the same thing in Windows 2000. While AutoDeFrag is by no means a new piece of software, it continues to be useful and has the potential to significantly reduce desktop problems, as well as to increase user productivity at a cost that makes it even more valuable for any enterprise: free.

How it works
Windows 2000 lacks a built-in method of launching the disk defragmentation utility from the command line at regularly scheduled intervals using the AT command. The executables that launch the two versions of the Windows 2000 disk defragmentation utility—Dfrgfat.exe and Dfrgntfs.exe—can’t be launched from the command line. When you try, you are presented with an error box indicating this fact. This is where AutoDeFrag comes in.

AutoDeFrag is a small application that, when executed, launches the built-in disk defragmentation utility in Windows 2000. This allows the utility to be run via the AT command or the Task Scheduler, without the need for a help desk person to visit a machine or for a user to have to remember to do it.

Using AutoDeFrag is as simple as the task it accomplishes. Simply download the utility and run the executable. Once you have it installed, type autodefrag at the command line. If you want to defragment a specific drive, type autodefrag <drive letter> instead. If you do not specify a specific drive, all drives in the system will be defragmented.

Running it on a schedule
As we mentioned, there are two ways to use this utility to automatically schedule a disk defrag in Windows 2000: via the AT command-line utility and using the Task Scheduler. We’ll demonstrate each approach by scheduling a defrag every Friday at 11:00 P.M.

Use the AT utility, followed by a listing of the scheduled commands as shown here:
C:\winnt>at 23:00 /every:friday autodefrag
Added a new job with job ID = 1

You can then check to make sure that it’s scheduled to run by issuing this command.

Now, let’s schedule AutoDeFrag with the Task Scheduler wizard, found in the Control Panel. As you can see in Figure A, starting 12/16/2001, I will be running AutoDeFrag every Friday at 11:00 P.M.

Figure A
Scheduling AutoDeFrag with the Task Scheduler

Summing up
While some organizations are moving to Windows XP, which includes support for a command-line launch of a defrag utility, many others will be sticking with Windows 2000 for the foreseeable future and should find a way to incorporate a regular defrag on each desktop machine. AutoDeFrag allows you to accomplish this without the intervention of the end user or an administrator.

How do you currently handle defrags? Will this tool help?

We look forward to getting your input and hearing about your experiences regarding this topic. Post a comment or a question about this article.