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

3 comments:

Anonymous said...

Thats a very nice tip, and definitely one not known to many users.

But, IMO, the windows defragger still falls short in performance (defrag times, resource usage) when compared to something like Diskeeper. DK has this autodefrag mode, which I have been checking out on the trial version, and its quite nifty. Runs in the background to defrag in real-time as is necessary, but also can be started on a preset schedule if required. dkservice.exe takes only a few MB of RAM and even the autodefrag hasnt shown any signs whatsoever of interfering with regular usage of the workstation. The fact that you dont need to defrag manually, save for the occasional boot defrag, is quite welcome.

Anonymous said...

dude you got a pc! thats to bad. mac's don't need defag.

Josh Phillips said...

Calm down, MacMan...I use a Mac too (check out previous posts on integrating Macs with AD Domains). However, the majority of the world is still stuck in Windoze, and I want to be helpful to the masses. ;-)