Nov 9, 2008

Scripting a Defrag

Anybody who is anybody knows that the built in Windows defrag utility stinks. It is very hard to schedule defrag and have it work correctly. The problem with that is that if you don't automate it, it will likely never get done, then you will start to see a lag in performance.

For those of you not "in the know", the reason defragging your hard drive is a good idea is because of the way Windows writes data to the hard drive. Windows doesn't write your word document in one continuous chunk on the hard drive. It breaks it up and puts the pieces where there is open space all over your drive. Over time, these fragments get out of control, and it takes the computer longer to find all of the pieces. It's kind of like your desk at work, with all sorts of papers strewn about. The defrag utility moves all of the pieces so they are back together again.

Now back to automation. There are lots of third part utilities out there for scheduling a defrag, and most of them cost money. The one I am going to talk about is a command line utility called DIRMS. Now, like some freeware products, DIRMS is no longer free, and comes only as trial ware. Once again, Bauer-Power to the rescue! I have the old free version available HERE. I have also included the script I wrote that will let you execute it without having to know much about running things from the command line. Just save it to the root of your C: drive (If you have a different letter, edit the batch file using notepad to use that letter).

The coolest part, is that since it is so easy to write a batch script for running it, it is even easier to automate. You can set the batch script to run as a scheduled task in windows. If you don't already know how to do that, click on Start> All Programs> Accessories> system Tools> Scheduled Tasks> Click on the Add Scheduled Task icon and follow the wizard. When it prompts you for which file to run, browse to the batch file, select it, and click OK.

I use it all the time, and it works great. I recommend setting it for a time when you aren't going to be using the computer, like sometime between midnight and when you wakeup (Yes, your computer has to be on to run it! I don't know how many times I have had users ask me if it okay to turn their computers off when they go home when I have set something to run after they leave. If you turn off your computer the scheduled task will not run. Simple as that!)

Once again, you can download it HERE.



Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | stopping spam