Sunday, August 23, 2009

You may not wish to rely on Windows Vista's Disk Defragmenter running on a schedule, preferring to perform this task manually via the command prompt. Or, you may need to create service-oriented batch files that defragment drives as a part of other maintenance tasks.

1. Click the "Start" button and type cmd.

2. When "cmd.exe" appears, right-click the icon and choose "Run As Administrator".

3. Confirm your actions if User Account Control (UAC) prompts you.

Now, for the command:

4. Enter the defrag command at the prompt, passing in the volume name to defragment. Several command line options are available (note the analyze options are described further in the tip Windows Vista - Disk Defragmenter: Analyze Fragmentation Status):

-a: Only performs drive analysis, not a defrag

-c: Instead of defragmenting a particular drive, this will defragment all volumes on the machine

-f: Though this option is not recommended, it will attempt to defragment the drive even if there is a low amount of free hard drive space

-r: Performs the default partial defragmentation, only consolidating fragments smaller than 64MB

-v: Displays extra information when performing the defrag or analysis

-w: Performs full defragmentation, attempting to consolidate all file fragments regardless of size

-?: Displays the help information

For example, the following command will defragment all drives on the system, displaying extra information about the process:

defrag -c -v

This command only defragments drive E:, but it will attempt to defragment all files regardless of size:

defrag -w e:

0 comments: