Last Update: Sep 24, 2024 | Published: Jan 07, 2009
When you make frequent writes and deletions from your hard disk your disks will become fragmented with time. Fragmentation of the disks will result in lower I/O performance. In order to prevent loss of performance over time, it is best to perform routine defragmentations of your hard disks.
Manual defragmentation of you disks is possible (see below), but since it tends to take a lot of time, it is best to schedule it to automatically run while you are asleep or away from your computer.
BTW, disk maintenance is also covered in the Schedule Disk Cleanup to Run Automatically in Windows XP/2003 article.
Windows XP/2003 has 2 built-in tools to assist in performing the necessary defragmentations of the disks.
Note: The volume must have at least 15% free space for Defrag to completely and adequately defragment it. Defrag uses this space as a sorting area for file fragments. If a volume has less than 15% free space, Defrag only partially defragments it.
Note: You must be a member of the local Administrators group in order to defragment your partitions, however you can run the commands with the RUNAS command:
runas /user:[email protected] "mmc dfrg.msc"
In the Scheduled Task Wizard dialog, type a name for the scheduled task (for example type Disk Defrag).
Select the frequency at which you want the Disk Defragmenter task to run (Every Day, Weekdays, or Every <N> days, where <N> is the number of days between scheduled runs). Click Next.
Add the drive letter for the drive you wish to defragment to the command in the Run text box. If you want to defragment drive C:, your Run command should look like this:
C:'WINDOWS'SYSTEM32'defrag.exe C:
Click OK
Only one instance of Disk Defragmenter can be running at any given time. If you have multiple partitions you’ll need to add a separate scheduled task for each one, and make sure you give each task a different starting time, allowing for the previous one to finish.
You can also use the AT command from the Command Prompt.
at 20:00 /interactive /every:M,T,W,Th,F,S,Su "defrag c: -f"
You can view the available scheduled tasks by typing AT and pressing Enter.
C:'WINDOWS'at Status ID Day Time Command Line ------------------------------------------------------------ 1 Each M T W Th F S Su 20:00 PM defrag c: -f"
Bingo.
You may find these related articles of interest to you:
Description of the New Command Line Defrag.exe Included with Windows XP – 283080
How to Defragment Your Disk Drive Volumes in Windows XP – 314848
Disk Defragmenter Limitations in Windows 2000, Windows XP, and Windows Server 2003 – 227463
How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows XP – 555098