Get Detailed Statistics By Running Windows Vista Disk Defragmenter From The Command Prompt
For reasons beyond common sense, Microsoft decided to turn Vista disk defragmenter utility into a faceless tool that no longer displays the graphical overview when running analysis or defragmentation on a disk Volume. While the GUI interface does nothing to report information or status information, a better way to generate detailed reports and perform other advanced tasks is to run disk defragmenter tool from the command line.
Unlike Windows XP disk defragmenter tool, Vista interface only allows you to modify the schedule and start the defrag:

The GUI also does not allow you to defrag individual Volumes, perform an analysis, or provide any useful reporting. Ironically no defrag information can be found in Vista event logs or Performance and Reliability tool.
Fortunately, running disk defragmenter from the command prompt (you will need Admin rights), gives you greater control of which volume or volumes to defrag, allows you to run analysis and view detailed reports. To view disk defragmenter available command line options, open a command prompt and enter the following command:
defrag.exe /?
which displays the following output:
Description: Locates and consolidates fragmented files on local volumes to improve system performance.
Syntax: defrag.exe <volume> -a [-v]
defrag.exe <volume> [{-r | -w}] [-f] [-v]
defrag.exe -c [{-r | -w}] [-f] [-v]
Parameters:
Value Description
<volume> Specifies the drive letter or mount point path of the volume to be defragmented or analyzed.
-c De fragments all volumes on this computer.
-a Performs fragmentation analysis only.
-r Performs partial defragmentation (default). Attempts to consolidate only fragments smaller than 64MB.
-w Performs full defragmentation. Attempts to consolidate all file fragments, regardless of their size.
-f Forces defragmentation of the volume when free space is low.
-v Specifies verbose mode. The defragmentation and analysis output is more detailed.
-? Displays this help information.
Below are defrag.exe examples:
defrag.exe d: (defrag the D: drive)
defrag.exe d:\vol\mountpoint -w -f (defrag the mountpoint while consolidation all file fragments regardless of size and if volume space is low, forces it to defrag)
defrag.exe d: -a -v (run analysis on the D: drive and set verbose mode for detailed output)
defrag.exe -c -v (defrag all volumes on your Computer and set verbose mode for detailed output)
An example output, shown below, runs analysis on the C: drive with verbose mode:

As you can see, a more detailed analysis is shown with information at the bottom indicating that the volume is not fragmented. A similar report will be displayed after fragmenting a volume.
While Vista graphical defrag utility does a nice job of making sure your disk drives are free from fragmentation, using the combination of defrag.exe from the command line for analysis will finally give you a better picture of your disk volumes that is lacking with Vista.
7 Comments on Get Detailed Statistics By Running Windows Vista Disk Defragmenter From The Command Prompt »
July 18, 2007
Herb Tarlek @ 1:27 pm:
Command line defrag requires Admin permissions. You don't mention this at all!
Watching The Net @ 5:24 pm:
Thanks Herb for catching that!!
October 26, 2007
russ @ 9:17 pm:
How come it says I need administrative permissions even though I'm using an administrator user. I need help. Thanks.
russ @ 9:26 pm:
Oh never mind, I got it already. Sorry I wasn't paying attention to what I was doing.
November 29, 2007
Andrey @ 6:17 am:
excellent! thanks!
February 6, 2008
Fred Tovey @ 11:32 am:
As you might expect, the scheduled task just runs this command line tool (which you can see by looking in Scheduled Tasks). Interestingly, it uses an undocumented switch of -i.
I can't find any info on this - does anyone know what this switch does? Are there any other undocumented controls for this program?
Watching The Net @ 4:52 pm:
@Fred Tovey
-i is used to pause the defrag when the computer is NOT in an idle state (in use). I believe this is a new switch with Vista.