Running Disk Defragmenter from a Command Line in Vista

The command-line version of the Disk Defragmenter allows you to exercise fine-grained control over the defragmentation process and uses the exact same program code as the scheduled version.

To use this command for a specific drive, type defrag d: at any command prompt, where d is the drive letter or mount point of an existing volume.

You can use the following switches with the Defrag command:

-c Defragments all volumes on the computer; use this switch without specifying a specific drive letter or mount point.

-a Analyzes the selected drive or volume and displays a summary of the analysis report.

-r Performs a partial defragmentation by consolidating only file fragments that are below 64 MB in size. This is the default setting.

-w Performs a full defragmentation by consolidating all file fragments, regardless of size.

-f Forces defragmentation of the volume even if the amount of free space is lower than normally required. Use this option with caution, as it can result in slow performance.

-v Displays complete (verbose) reports. When used in combination with -a, this switch displays only the analysis report. When used alone, it displays both the analysis and defragmentation reports.

In addition to the documented switches listed above, the command-line Defrag utility includes two useful but undocumented switches.

-i The –i switch makes Defrag run in the background and operate only if the system is idle - as it does when run as a scheduled task. If you want to perform the scheduled defrag early, use this switch, but leave it off if you're defragmenting a disk as part of major file operations.

-b The –b switch optimizes boot files and applications while leaving the rest of the drive undisturbed.

The command-line Disk Defragmenter does not provide any progress indicator except for a blinking cursor. To interrupt the defragmentation process, click in the command window and press Ctrl+C.





Tags: boot,cmd

Related Articles