Does your PC just not run as fast as it did when you first got it? Chances are your hard drive has become fragmented. What does this mean? Well, your hard drive is made up of many "slices" which are called sectors. When you create a Word document or download a song onto your computer it is written onto your hard disk. When you delete the file it is erased from the hard disk leaving an open space on your hard drive. Then you download the pictures from your latest vacation and part of the data is written to that now empty space and the rest to another part of your hard drive. Over time, after many songs, pictures, movies, etc your data is spread out all over the hard drive. This causes delays in reading the data off the hard drive when you want to show grandma your vacation pictures. Wikipedia has a lot more info on fragmentation.
This is where programs called disk defragmenters come into play. They analyze your hard drive and move the bits that are spread all over the place closer together. Your copy of Windows comes with a basic defragmenter and there are programs you can purchase. The Windows defragmenter will do in a pinch but it is very basic and takes some work to automate. The commercial defragmenters do a lot more, such as "Set it and forget it", but this comes at a price. I like programs that are free. I use a open source program called UltraDefrag. Diskeeper is a good commercial defragmenter, it is what I use at work.
You can run UltraDefrag using a graphical user interface or schedule it as a Windows task. I will walk you through setting up UltraDefrag as a scheduled task.
First you must download the latest version of UltraDefrag. As of August 2007 1.04 is the latest version.
Next we must decide what version we are going to download. If you are running Windows XP 64 or Vista 64 you need to select the amd64 package. If you are running 32-bit XP or Vista the i386 version is what you need.
Download and install the version you require, if the install does not work you picked the wrong version. It would be nice if in future versions the installer queried your system to determine the correct version to install, but there are really only 2 choices for the installer. If one does not work, try the other.
Now we are going to write a program. It is a very basic program but it will be the brains behind setting up free automated disk defragmentation.
Use Windows Explorer to navigate to "C:\Program Files\UltraDefrag\".
Click on File, New, Text Document. A new file called "New Text Document.txt" will be listed along with the UltraDefrag program files.
Right click on it and choose rename & type "defrag.bat".
Next right click on "defrag.bat" and choose Edit.
Now we start programming! We need to write the command to tell windows to use UltraDefrag to run on our system, compact our fragmented files and what hard drive we want this to run on.
Lets start with the command to run UltraDefrag. Type "defrag" (without the quotes) and press the space bar once. This tells Windows to start the UltraDefrag program.
Now type "-c" and add a space after it. This tells the program to defrag your hard drive.
Finally type "c:". This tells the program to defrag your C:\ drive.
Now click on File, Save. You have written your first program, go ahead and pat yourself on the back, you are on your way to becoming computer geek. ;-)
Next we are going to schedule Windows to run our program each Tuesday at 2AM.
Click on Start, Settings, Control Panel, then open Scheduled Tasks. Now click on "Add Scheduled Task".
A wizard opens up to walk you through setting up the task, click "Next".
Click on the "Browse" button and navigate to C:\Program Files\UltraDefrag & click on your program "defrag.bat". Now click on Open.
Next choose when you want to run the task, choose "Weekly". Click "Next".
Now we set the time and day of our task, set this to 2AM and Tuesday. Click "Next".
Now we have to assign the task to a user. Enter the username and password of the computer administrator. Most likely this will be your username and password. Click "Next".
Click on "Finish" to end the wizard.
Now every Tuesday at 2AM UltraDefrag will run on your computer to defragment your files.
Below is a screencast showing me running through this process. Enjoy.



August 16th, 2007 at 6:29 amQuote
I read an article recently which talked about fragmentation as a disease that silently killed the performance of a system. I think thats an apt analogy because its something that is easy to ignore, but it keeps growing over time to create such a big mess that it becomes difficult to for the HDD to do anything ‘on time’ which leads to the maddening lags and freezes.
August 16th, 2007 at 7:51 amQuote
I totally agree with the disease comment, I wish I had thought of it.
April 4th, 2008 at 7:32 amQuote
Hi, This may sound like a daft question but when you program it to run at 2:00AM, does this run whilst the pc is turned off? Because i don’t really want to set it at 2:00AM if it only runs when the pc is on as at 2Am i will be asleep and the pc will be off haha =]
Thanks, Louis =]
April 4th, 2008 at 9:13 amQuote
No it would not run.
You would need to go into the Scheduled tasks area, open the task and click on the settings tab. Down at the bottom there is a check box under Power Management to “Wake the computer to run this task.”
I have never tried this option as my PC runs 24/7, so it may or may not work for you.
Let me know how it turns out.
Dave
July 17th, 2008 at 8:27 pmQuote
I’ve come across another way to wake your PC to make this task run at 2AM. In most newer BIOS’ there is a setting to turn on the PC at a set time. Different manufacturers call it different things, but it can be found in the power management area of your BIOS.