Learn What IT Pros Need to Know About Windows 11 - August 26th at 1 PM ET! Learn What IT Pros Need to Know About Windows 11 - August 26th at 1 PM ET!
Disk Management

How can I schedule the Disk Defragmenter to run automatically in Windows XP/2003?

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.

Sponsored Content

Say Goodbye to Traditional PC Lifecycle Management

Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.

  1. Dfrg.msc – The GUI-based Disk Defragmenter MMC is based on the full retail version of Executive Software Diskeeper. This version of Disk Defragmenter MMC that is included with Windows XP has the following limitations:
  • It can defragment only local volumes.
  • It can defragment only one volume at a time.
  • It cannot defragment one volume while it is scanning another.
  • It cannot be scheduled. If you need to schedule disk defragmentation, use the Defrag.exe command line tool.
  • It can run only one MMC snap-in at a time.
  1. Defrag.exe – A Command Line tool. This means you can use the XP/2003 scheduler to automate the defragmenting of your partitions.

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"

Method 1 – Using Schedule Tasks

  1. Open Control Panel, double-click Scheduled Tasks
  2. Double-click Add Scheduled Task

  1. On the Scheduled Task Wizard dialog, click Next.

  1. Click Browse and navigate to windows’system32 folder. Select defrag.exe and click Open.

In the Scheduled Task Wizard dialog, type a name for the scheduled task (for example type Disk Defrag).

  1. Under Perform this task, select how often you wish Disk Defragmenter to run. Click Next.

  1. Set the time at which you wish the Disk Defragmenter scheduled task to run. This should be a time when your computer is turned on but not under heavy use (i.e. at night time).

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.

  1. Enter a user name under which the Disk Defragmenter scheduled task will run. This user must be an administrator on the local machine (see note above). Enter the password for that user and confirm it. Click Next.

  1. Check Open advanced properties for this task when I click Finish, and click Finish.

  1. In the Run text box, you can see the full path and command for defrag.exe.

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

  1. In the Set Account Information dialog, enter and confirm the password for the user listed in Run as and click OK.

  1. Task Scheduler will automatically run Disk Defragmenter with the settings you selected at the time you selected.

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.

Method 2 – Using the AT command

You can also use the AT command from the Command Prompt.

  1. Go to Start > Run, then type CMD and press Enter.
  2. In the Command Prompt window type
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.

Further Reading

You may find these related articles of interest to you:

Links

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

Related Topics:

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register
Comments (5)

5 responses to “How can I schedule the Disk Defragmenter to run automatically in Windows XP/2003?”

  1. Scheduling defrag | Allaboutlovepo

    [...] Schedule Disk Defragmenter to Run Automatically in Windows XP …Jan 8, 2009 … When you make frequent writes and deletions from your hard disk your disks will become fragmented with time. Fragmentation of the disks will … [...]
  2. Schedule defrag | Gotcustomers

    [...] Schedule Disk Defragmenter to Run Automatically in Windows XP …Jan 8, 2009 … When you make frequent writes and deletions from your hard disk your disks will become fragmented with time. Fragmentation of the disks will … [...]
  3. Dfrg schedule | Sheilahirt

    [...] Schedule Disk Defragmenter to Run Automatically in Windows XP …Jan 8, 2009 … BTW, disk maintenance is also covered in the Schedule Disk … Dfrg.msc – The GUI-based Disk Defragmenter MMC is based on the full retail … [...]
  4. Schedule defragment | Kiddygrips

    [...] Schedule Disk Defragmenter to Run Automatically in Windows XP …Jan 8, 2009 … When you make frequent writes and deletions from your hard disk your disks will become fragmented with time. Fragmentation of the disks will … [...]
  5. Schedule defragmenter | Keikohiraoka

    [...] Schedule Disk Defragmenter to Run Automatically in Windows XP …Jan 8, 2009 … When you make frequent writes and deletions from your hard disk your disks will become fragmented with time. Fragmentation of the disks will … [...]

Leave a Reply

Register for Advanced Microsoft 365 Day!

GET-IT: Advanced Microsoft 365 1-Day Virtual Conference - Live August 24th!

Join us on Tuesday, August 24th and hear from Microsoft MVPs and industry experts about how to take advantage of Microsoft 365 at a technical level and dive deep into the features and functionality that will make your environment more secure and compliant.

RSVP Now

Sponsored By