Featured Resource:

line

Newsletter

Email Address:


line

Ask the Expert

Have a question for our resident expert? Email your questions to Bob or post in the Forum.

« Running PowerShell Scripts | Main | File Explorer Enhancements: The Small Stuff »

Disk Defragmentation in Vista

Windows Vista now comes with an automatic disk defrag tool that is enabled by default. Specifically, it is set to run at 1am every Wednesday. You can disable or modify this by performing the following steps:

1) Click the “Start Orb”
2) Click the Control Panel
3) Click “System and Maintenance”
4) Finally, choose “Defragment your hard drive” from under “Administrative Tools” (at the bottom of the menu/list).

Or, my favorite/quick way:

1) Press the “Windows Button” on your keyboard, type “Disk Defrag” and press enter.

Again, the power of typing what you want to run in the search field at the bottom of the start menu is a huge time saver. I’ve read a few books now that talk about “Run” missing from the start menu as though it is a horrible thing, with instructions on how to get it back. There really is no need—the search field does the job better than Run ever did. And if you really want run for any reason, pressing “Windows” and “R” together still does the trick.

But I digress…

The defrag menu is as shown in the image below. You can simply uncheck the “Run on a schedule” box to disable it, or pres the “Modify schedule” button to pick a new time.

defrag.jpg

But that’s for users. What you need is a nice command line interface and you’ve got it here...

defrag -a [-v]
defrag [{-r | -w}] [-f] [-v]
defrag -c [{-r | -w}] [-f] [-v]

Specifies the drive letter or mount point path of the volume to be defragmented or analyzed
-c = Defragments all volumes on this computer
-a = Performs fragmentation analysis only
-r = Performs partial defragmentation (default). Attempts to consolidate only fragments smaller than 64 megabytes (MB)
-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 = Verbose mode; the defragmentation and analysis output is more detailed

For example, to check how things are doing on one of my test systems, I ran “defrag c: -a” and got the following back at the command line (note that you must run the command prompt as Admin).

Windows Disk Defragmenter
Copyright (c) 2006 Microsoft Corp.

Analysis report for volume C:

Volume size = 16.00 GB
Free space = 7.92 GB
Largest free space extent = 4.78 GB
Percent file fragmentation = 0 %

Note: On NTFS volumes, file fragments larger than 64MB are not included in the fragmentation statistics

You do not need to defragment this volume.

Ahh... now that feels good.

Comments

I just got this HP laptop with Vista premium. In system tools, it is not possible to get disk fragmentation statistics. I tried entering this "defrag c: -a" in command screen and nothing happened. Any suggestion to obtain fragmentation statistics would be greatly appreciated.

Post a comment

(All comments are approved by site leader before appearing here. Thanks for commenting!)

Library Resources

line
line

Bob Kelly's Bio:

Bob Kelly is the founder of AppDeploy.com — a resource focused on desktop management products and practices. He is author of the Start to Finish Guide to Scripting with KiXtart and The Definitive Guide to Windows Desktop Administration. He is also president and co-founder of iTripoli, Inc. who provide AdminScriptEditor.com, home to an integrated suite of scripting tools and a shared library of scripts and language help. Not enough? For more on Bob click here.