Wednesday, July 11, 2007

Scheduling Defrag in XP

The Windows XP Disk Defragmenter tool is located in the Microsoft Management Console (MMC), thus making it impossible to schedule a regular defragmenting session using the Windows XP Task Scheduler. However, there is a command line version of this utility (Defrag.exe), that you can schedule. To do so, you must create a batch file that runs Defrag.exe along with the appropriate parameters, and then create a schedule to run this 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.

Your computer will regularly run the defrag batch operation to help keep your Windows XP system running smoothly.


Josh Phillips
ProVisionIT
www.provisionit.com