The Microsoft Management Console houses the Windows XP Disk
Defragmenter, which makes it impossible to schedule a regular defragmenting session via Task Scheduler. However, there’s
also a command line version of this utility, called Defrag.exe,
that you can schedule. To do so, create a batch file that runs
Defrag.exe along with the appropriate parameters, and then create a schedule to
run your batch file.

To run Defrag from the batch file, use the following command

Defrag x:

In this command, x
is the drive letter of the hard disk you want to defragment,
and parameter is one of three
optional settings that you can use to configure Defrag:

  • /a: Analyzes the volume and displays a summary of the
    analysis report.
  • /v: Displays the complete analysis and defragmentation
    reports. Can be used
    in combination with /a to display only the analysis
  • /f: Forces defragmentation of the volume regardless of whether it
    needs to be defragmented.
  • Here’s how to schedule the Disk Defragmenter:

    1. Launch Notepad.
    2. Type the appropriate Defrag command line.
    3. Save the file as Defragger.bat.
    4. Go to Start | All Programs | Accessories | System Tools |
      Scheduled Tasks.
    5. Launch the Scheduled Task Wizard by double-clicking Add
      Scheduled Task.
    6. Click Next and select Defragger.bat.
    7. In the following three screens, select the Weekly or
      Monthly option, the time that you want to defragment
      your hard disk, and then type a username and password
      with Administrative privileges.
    8. Click Finish.

    Now, your computer will regularly run
    a defragmentation operation to keep your Windows XP
    system in tip-top shape!

    This tip applies to both Home and Professional editions.

    Miss a tip?

    Check out the Windows XP archive, and catch up on our most recent Windows XP tips.

    Stay on top of the latest XP tips and tricks with our free Windows XP newsletter, delivered each Thursday. Automatically sign up today!