XP Defrag is commandline capable

  • Section(s): Utilities
  • Published on Apr 20, 2004.
  • Last Modified on Apr 20, 2004.
  • Last Modified by Wayne Maples.
  • Rated 4.3 out of 5 based on 21 votes.
Windows XP defrag program has a commandline interface. This means you can use XP's scheduler to automate the defragmenting of your partitions. To get the options for defrag:
C:\>defrag

Windows Disk Defragmenter
Copyright (c) 2001 Microsoft Corp. and Executive Software International, Inc.
Usage:
defrag  [-a] [-f] [-v] [-?]
  volume  drive letter or mount point (d: or d:\vol\mountpoint)
  -a      Analyze only
  -f      Force defragmentation even if free space is low
  -v      Verbose output
  -?      Display this help text

When I defrag the C: partition:

C:\>defrag c: -f
Windows Disk Defragmenter
Copyright (c) 2001 Microsoft Corp. and Executive Software International, Inc.

Analysis Report
    4.98 GB Total,  2.69 GB (54%) Free,  4% Fragmented (8% file fragmentation)

Defragmentation Report
    4.98 GB Total,  2.69 GB (54%) Free,  0% Fragmented (0% file fragmentation)
In the following, I schedule the C: partition to be defragged at 6pm, D: at 7pm, and E: at 8pm.

C:\>at 18:00 /interactive /every:M,T,W,Th,F,S,Su "defrag c: -f"
Added a new job with job ID = 1

C:\>at 19:00 /interactive /every:M,T,W,Th,F,S,Su "defrag d: -f"
Added a new job with job ID = 2

C:\>at 20:00 /interactive /every:M,T,W,Th,F,S,Su "defrag e: -f"
Added a new job with job ID = 3

C:>at
Status ID   Day                     Time          Command Line
-------------------------------------------------------------------------------
        1   Each M T W Th F S Su    6:00 PM       "defrag c: -f"
        2   Each M T W Th F S Su    7:00 PM       "defrag d: -f"
        3   Each M T W Th F S Su    8:00 PM       "defrag e: -f"

About Wayne Maples

Share this article


Article not looking right or info is missing? Let us know so that we can fix it: .


Receive all the latest articles by email!

Receive Real-Time & Monthly WindowsNetworking.com article updates in your mailbox. Enter your email below!
Click for Real-Time sample & Monthly sample

Become a WindowsNetworking.com member!

Discuss your network issues with thousands of other network administrators. Click here to join!

Community Area

Log in | Register

Readers' Choice

Which is your preferred Firewall & VPN hardware solution?