Defrag Windows from Command Prompt

If it were up to me, I'd never defragment my PC's drives. I'm one of those people who prefers to have Windows' maintenance operations done in the background, without my direct intervention.

So it comes as no surprise that I'm a big fan of Vista's automatic-defrag setting. But I also know better than to put all my faith in Microsoft's ability to keep my system healthy. Last year, I started using Auslogics' free Disk Defragutility, which works with Windows 2000 and up.

If you prefer to use Windows' defragger, you can open it by pressing the Windows key (or Ctrl-Esc), pressing R (in XP), typing defrag in Vista or dfrg.msc in XP, and pressing Enter. The interface of Vista's Disk Defragmenter is nonexistent; the utility is clearly designed for behind-the-scenes operation. Your only options are to set the defrag schedule, select the volumes to defrag, and run the defragger.

Windows Vista Disk Defragmenter utility

Vista's Disk Defragmenter utility is a no-frills affair.

(Credit: Microsoft)

XP's version of the Disk Defragmenter isn't much more functional, although it does give you a little more graphical feedback about the state of your drives.

You get more control over your disk defrags by running Windows' defragger utility from a command prompt and entering command switches that modify its actions. Start by opening a command-prompt window. One way is by pressing the Windows key (or Ctrl-Esc), pressing R (in XP), typing cmd, and pressing Enter. Or click Start > All Programs > Accessories, right-click Command Prompt, and select Run as administrator.

At the command prompt, type defrag ? to see a list of available command switches. In both XP and Vista, you can add -a to the "defrag" command to analyze the drive only, -f to force a defrag with less than 15 percent free space, -b to defrag only boot files, and -v to show a "verbose" report of the defrag.

Vista adds a couple of other switches: -i defrags even when the PC isn't idle, -c works on all drives, and -wprocesses chunks of files smaller than 64MB; without this switch, Vista's defragger ignores all file fragments smaller than 64MB.

Defrag command switches

Type defrag ? at a command prompt and press Enter to see a list of available command switches.

(Credit: Microsoft)

For example, to defrag all your Vista volumes regardless of fragment size and when there's less than 15 percent free space, enter this line at the command prompt and then press Enter:

defrag -c -w -f

The utility will display a report on the selected volumes prior to beginning the defragmentation.

Windows Disk Defragmenter report

Windows defrag utility will show a report on the selected volumes prior to defragmenting the drives.

(Credit: Microsoft)

Unfortunately, defrags run from a command prompt aren't any faster than those conducted via the graphical interface. That's the biggest advantage of specialty defrag programs such as Auslogics' Disk Defrag, which is much speedier than the defragger in Windows.

The fact is, Vista's automated defrags were doing a great job of keeping my disk space nice and compact. I didn't notice much of a performance improvement after I manually defragged my Vista PC, but the defrag did wonders for my ancient XP box, which I admit I had neglected to defrag for many months.

The other day, I was talking to a guy who wanted a PC but didn't want Vista. He asked me how long he would have to wait for new PCs running Windows 7. When I told him that such systems were still several months away, he indicated that he'd buy a machine from a company that let you "downgrade" Vista to XP.

I didn't say anything, but part of me thought he was crazy. I'll take Vista over XP any day of the week. Not having to run a disk-defrag utility is only one of the reasons why. (Yes, I know you can automate disk defrags in XP via Scheduled Tasks, as Microsoft explains in this Knowledge Base article, but doing so is too much hassle for the average Windows user.)

No response to “Defrag Windows from Command Prompt”

Leave a Reply

Page Navigation

 
span.fullpost {display:inline;}