How to Automate Disk Defragging in Windows XP - InformationWeek
Cloud // Cloud Storage
08:53 AM
Moving UEBA Beyond the Ground Floor
Sep 20, 2017
This webinar will provide the details you need about UEBA so you can make the decisions on how bes ...Read More>>

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
Newest First  |  Oldest First  |  Threaded View
How Enterprises Are Attacking the IT Security Enterprise
How Enterprises Are Attacking the IT Security Enterprise
To learn more about what organizations are doing to tackle attacks and threats we surveyed a group of 300 IT and infosec professionals to find out what their biggest IT security challenges are and what they're doing to defend against today's threats. Download the report to see what they're saying.
Register for InformationWeek Newsletters
White Papers
Current Issue
IT Strategies to Conquer the Cloud
Chances are your organization is adopting cloud computing in one way or another -- or in multiple ways. Understanding the skills you need and how cloud affects IT operations and networking will help you adapt.
Twitter Feed
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.
Flash Poll