Scheduling Defrag

Have you ever asked your computer geek about problems you are having with your computer? Has his answer ever been "when was the last time you defragged your hard drive?" What kind of answer is that? That doesn't help any. Now, you have to sit in front of your computer for 3, 4, 5, or 10 hours while this application ran. And to top that off, you didn't know what you were even looking at! Well, I have found the answer. Kelly's Korner has an article talking about scheduling the defragger that comes with Windows. The article can be found here. You want to scroll down to the Add a Scheduled Task section.

But, to keep you from looking it up, here are the basics:

1. — open up notepad

2. — cut and paste the following code into the text window (this is from Kelly's Korner):

Set WshShell = WScript.CreateObject("WScript.Shell")
Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next
Set WshShell = Nothing

3. — Save the file. Make sure when you do you select all files in the Save as Type dialog box. If you don't notepad will autoappend .txt to the end of your filename. This is not what you want. You can save it where ever you want, just make sure you remember where you save it.

4. — Now, add a scheduled task to run the file. The ways to do this vary, but the control panel has a scheduled task wizard you can use to set one up.

I have mine scheduled to defrag every Saturday evening.

Leave a Reply

Your email address will not be published. Required fields are marked *