Get Detailed Statistics By Running Windows Vista Disk Defragmenter From The Command Prompt

19

vistalogo.pngFor 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:

vistadefrag2.png


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:

vistadefrag1.png


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.

Filed under Windows Vista Tips by  #

Comments on Get Detailed Statistics By Running Windows Vista Disk Defragmenter From The Command Prompt Leave a Comment

July 18, 2007

Herb Tarlek @ 1:27 pm #

Command line defrag requires Admin permissions. You don't mention this at all!

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?

August 29, 2008

Lakshan @ 8:27 pm #

Right click the "Command Prompt" button and select "Run as administrator". A command prompt window will appear. Everything you run in this Window will be run with administrator rights. This is when asked for admin.

December 28, 2008

sara @ 9:37 pm #

hi there i am trying to defrag my dads computer and i can it says i need to be a administrator and i dont know how to do it tell me

January 29, 2009

Josh @ 5:50 pm #

@sara

If you want to use the command prompt defrag, right click the cmd executable (type cmd into the search box in your start menu) and click Run As Administrator. You will need to enter an admin password. Then when you run defrag you will have admin privs

December 10, 2009

chad @ 10:15 pm #

the windows vista dfragmentor always says the next scheduled run is "never". when i schedule a time and then close the screen and go back into it will say "never" again. how can i keep a scheduled dfrag time in vista?

February 22, 2010

Saa @ 7:13 am #

like @russ mentioned, i tried but it says needs admministrative permission even though i'm the only user in this computer?

i used the command>
defrag.exe c: -a

but it says>
This program needs to run with administrative permission. Use an administrator command prompt then run the program again.

Saa @ 7:18 am #

sorry. i know now. u can remove my comments

April 28, 2010

Sally @ 9:35 am #

I have the same issue with Vista. I cannot schedule disk fragmentation because it keeps resetting the Modify Schedule to Never. I have been unable to find any comments on this subject. I have to put a note on my calendar to remember to defrag every few months or so. If you find out anymore information on this subject would you please let me know?

Thanks,
Sally

December 2, 2010

john @ 7:38 pm #

@Herb Tarlek: OOOOHHHH Boy -We Got Us A NEWBIE! Read, young child, read. Right at the very beginning it states: "(You will need Admin rights)". As my kids would say "DUH!"
For the un-schooled: Right Click the Command prompt icon and Left Click (once) the "Run As Administrator" text (Click "Continue" if you have UAC (User Account Control) enabled). You will then be running the defrag routine as the Administrator login.

March 20, 2011

Russ @ 1:33 am #

Does anyone know how to disable all drives other than "C" drive in disk defrag in Vista? I have three hard drives with a partition in one of them. I get tired of disk defrag analizing all 4 disks every time (before and after) I try to defrag my C drive only. Any help would be very much appreciated.

July 30, 2011

pang @ 4:46 am #

Hi ! can i have the solution to reset admin password in vista basic ? pls show in detailed if u have ? THANKs .

January 24, 2012

Onur @ 5:43 pm #

Still missing something and same thing even on 7. The most useful information isn't given even when using command-prompt. That is, "most fragmented files!", where is it? I want to know most fragmented files per file like on XP, possible?

Leave a Comment

Fields marked by an asterisk (*) are required.

Subscribe without commenting