Windows XP includes the Disk Defragmenter MMC, which helps you maintain the disk performance by defragmenting volumes that use the FAT, FAT32, or NTFS file system. However, the Defragmenter MMC, a GUI tool, cannot be used with Task Scheduler.

To schedule disk defragmentation, you need to use the Defrag.exe command line tool, included in Windows XP. For additional information about using the command line Defrag.exe tool, visit the following page:

Description of the New Command Line Defrag.exe Included with Windows XP

This article tells you how to automate disk defragmenter with Task Scheduler in Windows XP. Screenshots are included at the bottom.

Using Defrag.exe with Task Scheduler

  1. Click Start, Run and type CONTROL SCHEDTASKS
  2. Double-click Add Scheduled Task, and click Next
  3. Click the Browse button to select the file Defrag.exe, present in %Windir%\system32 folder
  4. Specify a name for the task, and under Perform this task, and then choose one of the following options:
  • Daily
  • Weekly
  • Monthly
  • One time only
  • When my computer starts (before a user logs on)
  • When I log on (only after the current user logs on)
  1. Click Next, specify the information about the day and time to run the task, and then click Next.

    Note that the information about the day and time to run the task vary depending on the selection that you made in the previous wizard dialog box. For example, if you chose Weekly, you must indicate the day of the week, the time, and if the task should run every week, every 2 weeks, every 3 weeks, and so on.

  2. Type the name and password of the user who is associated with this task. Note that Disk Defragmenter requires Administrative credentials to run.
  3. Click to select the Open advanced properties for this task when I click Finish check box
  4. Click Finish
  5. In the Run box, specify the drive-letter and other parameters for Defrag.exe, and click OK.

Important note:   In the 9th step, you need to add the parameters for the Defrag.exe command. To defragment C:\ drive, the command-line would be:

C:\Windows\System32\Defrag.exe C:

For more information regarding the command-line parameters supported by defrag.exe, type Defrag.exe /? in a Command Prompt window. Scheduling Defrag.exe without any parameters will not help. If no parameters are mentioned, it will just simply execute with a exit code 0 (success), without defragmenting the hard drive.