On MovieTome: Captain America in IRON MAN?

Scheduling Disk Defragmenter in Windows XP

Tags: Greg Shultz, Microsoft Management Console, disk, Microsoft Windows XP, defragmentation, Microsoft Windows, batch file, Windows XP Tips Newsletter

  • Save
  • Print
  • Digg This
  • 9

Takeaway: You can't schedule a defrag using Task Scheduler, but you can do it from a batch file. Greg Shultz explains how to schedule Windows XP's Disk Defragmenter.

The Microsoft Management Console houses the Windows XP Disk Defragmenter, which makes it impossible to schedule a regular defragmenting session via Task Scheduler. However, there's also a command line version of this utility, called Defrag.exe, that you can schedule. To do so, create a batch file that runs Defrag.exe along with the appropriate parameters, and then create a schedule to run your batch file.

To run Defrag from the batch file, use the following command line:

Defrag x: [/parameter]

In this command, x is the drive letter of the hard disk you want to defragment, and parameter is one of three optional settings that you can use to configure Defrag:

  • /a: Analyzes the volume and displays a summary of the analysis report.
  • /v: Displays the complete analysis and defragmentation reports. Can be used in combination with /a to display only the analysis report.
  • /f: Forces defragmentation of the volume regardless of whether it needs to be defragmented.
  • Here's how to schedule the Disk Defragmenter:

    1. Launch Notepad.
    2. Type the appropriate Defrag command line.
    3. Save the file as Defragger.bat.
    4. Go to Start | All Programs | Accessories | System Tools | Scheduled Tasks.
    5. Launch the Scheduled Task Wizard by double-clicking Add Scheduled Task.
    6. Click Next and select Defragger.bat.
    7. In the following three screens, select the Weekly or Monthly option, the time that you want to defragment your hard disk, and then type a username and password with Administrative privileges.
    8. Click Finish.

    Now, your computer will regularly run a defragmentation operation to keep your Windows XP system in tip-top shape!

    Note: This tip applies to both Home and Professional editions.

    Miss a tip?

    Check out the Windows XP archive, and catch up on our most recent Windows XP tips.

    Stay on top of the latest XP tips and tricks with our free Windows XP newsletter, delivered each Thursday. Automatically sign up today!

    • Save
    • Print
    • Digg This
    • 9

    Print/View all Posts Comments on this article

    You can run defrag.exe from the Scheduled Taskspencer.salva@...  | 06/07/06
    Aah but...Laughing Jack  | 06/08/06
    Run task as adminccollins@...  | 06/08/06
    You can run defrag from a schedulecstaniar@...  | 06/08/06
    Use a local admin accountspencer.salva@...  | 06/08/06
    Another account to useJamesLucht@...  | 06/08/06
    I've tried that but it doesn't work for me,UncleRob  | 06/15/06
    define account to run assprinkl3s  | 06/15/06
    Scheduling Deframentre In Windows XPm_mehta52@...  | 07/18/06
    error windowD.H. Cesare  | 06/08/06
    Noalias@...  | 06/08/06
    YesRaven - cdn  | 06/08/06
    username/passwordD.H. Cesare  | 06/08/06
    NOyurkie@...  | 09/13/07
    error hmmcannible.flesh@...  | 06/15/06
    Or just do this free program to keep it from getting defraged1PebKac  | 06/08/06
    Agreed!kgouldsk  | 06/08/06
    Doesn't workD.H. Cesare  | 06/08/06
    Not that way, it won'trderuiter@...  | 06/08/06
    Nothing worksD.H. Cesare  | 06/08/06
    It will work.1PebKac  | 06/09/06
    I think you mean for getting fragmentedshraven  | 06/08/06
    Or use this batch file in GPghughes@...  | 06/08/06
    like itChrisfc  | 06/08/06
    Spybotrobmilleracs@...  | 06/09/06
    good solution, but..Chrisfc  | 06/09/06
    what we use for anti-spyware...Understaffed  | 06/11/06
    Unfortunately you're wasting money...UncleRob  | 06/15/06
    In a perfect world...Understaffed  | 06/16/06
    you may have saved money...UncleRob  | 06/16/06
    Did a little test...Understaffed  | 06/19/06
    unfortunately...UncleRob  | 06/15/06
    perimeter security versus spyware scannerChrisfc  | 06/17/06
    No doubtrobmilleracs@...  | 06/20/06
    Work with "domain users" and "logoff"?Understaffed  | 06/09/06
    GPO Basicsrobmilleracs@...  | 06/09/06
    I guess I meant...Understaffed  | 06/09/06
    no needyurkie@...  | 09/13/07
    System Slows Downrobertrichards@...  | 06/15/06
    re: system slows downsprinkl3s  | 06/15/06

    What do you think?

    Article Categories

    Security
    Security Solutions, IT Locksmith
    Networking and Communications
    E-mail Administration NetNote, Cisco Routers and Switches
    CIO and IT Management
    Project Management, CIO Issues, Strategies that Scale
    Desktops, Laptops & OS
    Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
    Data Management
    Oracle, SQL Server
    Servers
    Windows NT, Linux NetNote, Windows Server 2003
    Career Development
    Geek Trivia
    Software/Web Development
    Web Development Zone, Visual Basic, .NET

    advertisement
    Click Here