Scheduling a defrag of your hard drive can help to improve the performance of your computer and remove the burden of remembering to do it yourself. This guide will show you how to set up a scheduled defrag in Windows XP.
Defragging (or defragmenting) is the process of rearranging files on your hard drive so that they take up one contiguous space instead of being spread out in multiple places across the drive. This can speed up system performance since the drive heads don’t have to jump around to read a file and can access it all in one shot. It is a good idea to defragment your hard drive regularly, but it’s tough to remember and if you start it manually while you’re using your computer, then it really slows everything down until it’s done, and may not even run at all while other applications are running. It would be nice to be able to schedule the defragment process to run while you were away from your computer so you never have to think about it.
There are lots of disk defragger tools available for windows for free like Defraggler and MyDefrag, or to buy like Diskeeper. These 3rd party disk defragmenter utilities add a lot of nice features like scheduling and optimization but generally require installing a system services that constantly runs in the background, which just adds extra overhead to your already slow system.
The truth is that the built in windows defragging program does an adequate job, but doesn’t have a way for you to schedule it to run at a specific time. Using the task scheduler, also built in to Windows, you can schedule a defrag to run for free without running any 3rd party software or services. This is already set up in Windows Vista and Windows 7, but if you’re still using Windows XP, you can use these methods to schedule a defrag of your hard drives, automating the process.
Schedule by Hand:
The first method is to manually create a scheduled task by going to “start, all programs, accessories, system tools, then scheduled tasks.” Create a new task to run “c:\windows\system32\defrag.exe C:” under the administrator account.
Then, schedule it to run once a week or on whatever schedule you like.
Schedule via Command Line:
An alternate method is to use the schtasks command in a DOS command prompt to set the scheduled task. This is useful if you want to include it in a batch file for a startup script or push it through a domain group policy (GPO).
Here is an example of how to use schtasks to configure defrag.exe to run every Wednesday at 1:00 am under the local system account.
schtasks /create /TN Defrag /SC WEEKLY /MO 1 /D WED /ST 01:00:00 /RU SYSTEM /TR “c:\windows\system32\defrag.exe C:”
You will end up with a scheduled task that looks like this:
I use a remote system management tool called VNCScan and you can use the command line version of this to push the scheduled tasks to remote computers on your network.
Let me know how this worked for you or any questions or comments in the comments section below.
I’ve noticed some users are turning off their computers at night, so the defrag job never runs. For them I configured it to run at lunch time, but only if the computer has been idle for 10 minutes. You can see the settings below. It checks to see if their computer has been idle for 10 minutes and if not, retries for 60 minutes. I have also configured it to only defrag for an hour max so it won’t interfere with their work when the come back. I think if their computers are being defragged every week, it shouldn’t take more than an hour anyway.