Defragment your hard disk from the Command Prompt


In our previous article we mentioned that the Disk Defragmenter has been simplified a lot. In this new version, the user interface doesn't allow users to select only one of their partitions for defragmentation. You can defragment all your partitions at once or none. However, this doesn't mean that users they cannot customize the Disk Defragmenter at all.

You can always start the Command Prompt and use the appropriate command line parameters to obtain the results you want.

When you start the Command Prompt, it is better to right click on its shortcut and select the Run as administrator option.

Command Prompt

Once the Command Prompt is started, type "defrag" or "defrag.exe" plus the appropriate parameters and Disk Defragmenter will defragment or analyze the partition you want.

The list of supported command line parameters for "defrag.exe" is the following:

  • drive letter - this parameter specifies the drive letter or the mount point path of the volume that will be analyzed or defragmented. (e.g. "defrag c:" or "defrag e:\volume\mountpoint");
  • -c - using this parameters forces "defrag.exe" to defragment all volumes on your computer. (e.g. "defrag -c");
  • -a - performs only fragmentation analysis and it doesn't defragment the specified drive. (e.g. "defrag d: -a");
  • -r - performs a partial defragmentation which consolidates only the fragments which are smaller than 64 MB. This is the default setting. This means that "defrag v:" and "defrag v: -r" are equivalent and the Disk Defragmenter will perform the same type of defragmentation;
  • -w - when you use this switch, "defrag.exe" will perform a full defragmentation, regardless of the fragments size. (e.g. "defrag c: -w");
  • -f - forces the defragmentation even if the free space is lower than 15%. (e.g. "defrag c: -f");
  • -v - verbose mode. In this mode, "defrag.exe" will show a detailed analysis and defragmentation output. (e.g. "defrag d: -v");
  • -? - displays help information about how to use "defrag.exe". (e.g. "defrag -?").

The switches can be combined to obtain the desired result. You just need to respect the following syntax:
defrag volume -a [-v]
defrag volume [{-r | -w}] [-f] [-v]
defrag -c [{-r | -w}] [-f] [-v]

Here are some examples, to help you understand better:



Comments

how can you find the history

how can you find the history or scrip on your computer that shows you everything that has been done on your computer?

It never went anywhere...this

It never went anywhere...this is how manual administrative commands are done

Windows default defrag

Windows default defrag option is the safest, we should avoid using any third party applications.

riiiiight

Safe? Just run a chkdsk /f and reboot before defrag.

Many defrag tools out there are as limited as 'defrag'.
But some are excellent.

Contig (Microsoft Freeware) allow us to defrag any specific files.

UltraDefrag (Open Free Software) also allows us to defrag all
unmovable locked files when Windows boots. And -o and
set UD_IN_FILTER=pagefile;.evt;ntuser;System32\config
moves the most frequently used files to the fastest area of
our Drive, the beginning.

Verbose real-time?

If choosing verbose mode, do details come as they occur (like in the old Defragmenter where you could "watch it work"), or is it a detailed analysis that pops up all at once when the defrag is done???

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options