Cloud // Cloud Storage
08:53 AM

How to Automate Disk Defragging in Windows XP

Here's how to set XP to automatically defrag the system hard drive.

A large number of companies are still running XP. To keep your client machines running smoothly, it's always good to defrag the hard drive on a regular schedule. You can do it manually, but would need to rely on the end user to do so. Here's how to set XP to automatically defrag on a schedule.

To do this, you'll need an administrator level account with a password. All user-level scheduled tasks need a password in XP.

First, create a batch file. From the start menu, select run and in the text field type: cmd. Hit Enter.

In the command line, navigate to a folder where you’d like to save the batch file using the cd (change directory) command.

I changed to the utilities directory on my C drive by typing: cd utilities. After you select a subdirectory, type the following at the C:\prompt: echo defrag c: -f > defragc.bat

You just created the file. There’s no confirmation or other message if you did it correctly. Close out the command window.

Now from the Start menu, head to Programs >> Accessories >> System Tools >> Scheduled Tasks

Click Add Scheduled Task.

Now in the Scheduled Task Wizard, click Browse.

In the Browse menu, click Navigate to the location of the saved batch file. Select it and click Open.

Select how often you want the system to defrag. Click Next.

Enter a scheduled day of the week and a time for the defrag task. I usually schedule it for sometime after normal business hours. Remember your computer must be powered on for the job to run. Click Next.

Enter the password for the account the job will run under. By default, it will ask the password for the account you’re logged in as. Click Next.

Click Finish and you’re done. Setting up a regular disk defrag is an excellent habit to get into -- especially in XP, and now you don’t have to think about it. This will provide better performance of workstations, and less work for IT.

Based in Duxbury, VT, Jeremy Lesniak is a senior contributor at BYTE. Follow him @jlesniak and email him at

Comment  | 
Print  | 
More Insights
Google in the Enterprise Survey
Google in the Enterprise Survey
There's no doubt Google has made headway into businesses: Just 28 percent discourage or ban use of its productivity ­products, and 69 percent cite Google Apps' good or excellent ­mobility. But progress could still stall: 59 percent of nonusers ­distrust the security of Google's cloud. Its data privacy is an open question, and 37 percent worry about integration.
Register for InformationWeek Newsletters
White Papers
Current Issue
Twitter Feed
InformationWeek Radio
Archived InformationWeek Radio
Join us for a roundup of the top stories on for the week of April 19, 2015.
Sponsored Live Streaming Video
Everything You've Been Told About Mobility Is Wrong
Attend this video symposium with Sean Wisdom, Global Director of Mobility Solutions, and learn about how you can harness powerful new products to mobilize your business potential.