Windows XP comes with Disk Defragmenter, which
is a slimmed down version of Executive Software’s Diskeeper disk
defragmentation program. This utility is accessible via the
Computer Management Microsoft Management Console (MMC) and as a
stand-alone utility on the Tools tab of each hard drive’s
Properties dialog box.

There’s also a command-line version of this
utility called Defrag. If you want to quickly configure and launch
a defragment operation, it’s easier to use the command line rather
than accessing the GUI version and then drilling down through a
number of options.

To run Defrag, open a command prompt window and
type the following command:

Defrag x: [/parameter]

In this example, 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 report. It can be used in combination with /a to
    display only the analysis report.
  • /f: Forces defragmentation of the volume,
    regardless of whether it needs to be defragmented.

When you use either the /a or /v parameters,
Defrag displays the results on the command line. However, if you’d
rather have the results available as a file, use the DOS
redirection symbol to send the report to a file. For example, you
can redirect the results to a file called Defrag-Results.txt by
using this command:

Defrag x: [/parameter] > Defrag-Results.txt