The Weekly Geek

I'm the Geek so you don't have to be!

The Weekly Geek random header image

Auto Defragmentation of Window XP

November 21st, 2003 · No Comments

Howdy and welcome back to The Weekly Geek!

This week we are going to cover how to automatically have your system run the Defragmentation program that comes with Windows.

In previous versions of Windows, the task scheduler would open and run Disk Defragmenter. But in Windows XP, it simply opens Disk Defragmenter’s window. It does not actually start the utility. However, there is a way to make the program run in a DOS window:

  • Click “Start | All Programs | Accessories | System Tools | Schedule Tasks”. Double click “Add Scheduled Task”.
  • Click “Next” then select “Browse”. Navigate to “Windows | System32”. Click on “Defrag.exe | Open”.
  • In the Schedule Task Wizard, click “Monthly”.
  • Click “Next” then select the time and day.
  • Click “Next”. Enter your Windows password twice and click “Next”.
  • Check the box marked “Open advanced properties for this task then I click Finish”.
  • Click “Finish” in the Run box, you will find the path to the defrag.exe file. At the end of this string, add a space and “c:” (without the quote marks).
  • Click “Apply”. If you are asked for your password again, enter it then select “OK” then “OK” again.

The program will now run on the schedule you set. But it will run in a Command/DOS window (a black background with white text). It first analyzes the disk and reports on fragmentation. It then defragments the disk. It does not say that it is defragmenting, but you will see that the hard drive light is on. You’ll know when it quits defragmenting; the DOS window disappears.

Note that you need a Windows password to run the task scheduler. If you don’t have a password, you can establish one. Click “Start | Control Panel” and then double click “User Accounts”. Select the proper account. Then select “Create a password”. Fill in the blanks and click “Create Password”. Close the windows.

In Windows 2000 you need to be a little more extreme. There is a program called Autodefrag by MorphaSys you can download. Even though the program is old in computer terms (June 2001) it works and is free. The MorphaSys site gives you the basics that you need to know. Simply download their file to an appropriate location.

To set this up all you need to do is go to the command prompt (Start | Run | CMD) and type the following line (after you have downloaded AutoDeFrag and put it in the C:\winnt or C:\winnt\system32 folders). As you know by my recommendation for defragmenting hard drives is monthly but this will vary depending on how much you put on and take off your computer, as a result I suggest that you use the following line.

at 17:30 /interactive /every:3 “autodefrag

Since the computer used a 24 hour clock you are setting up a permanent run at 5:30pm on the 3rd of every month to run “autodefrag” which will run the Widows 2000 defrag on all of your hard drives then shutdown. The interactive line simply lets you see the defragmentation process.

For all versions of Windows, I suggest you remove the “pagefile.sys”. To do this, go to your virtual memory and select the check box to use no virtual memory (VM). To get to your VM go to “Start | Settings | Control Panel” and selecting the “System” icon.

  • When you do, you’ll see the “System Properties” sheet. Select the “Performance” tab. At the bottom right of the page you will see a “Virtual Memory” button, select it.
  • On the new screen that appears look for and select the check box by “Disable virtual Memory”. Select “OK” back out of the two open menus.
  • Do not reboot.
  • Go to your “Search” or “Find” depending on which version of Windows you use and search for “pagefile.sys” (without the quotes) and delete it. The “pagefile.sys” is hidden by default, so you’ll have to configure Windows to show hidden files before you’ll be able to see and delete it. Press the “Windows” key and the “E” key at the same time then choose “Tools” from the top list. Select “Folder Options”. The properties sheet’s “View” tab contains many choices one is the “Hidden Files and Folders” section. All the necessary options for working with hidden files are there.
  • Note: While there, just under where you are working, go ahead and remove the check mark for “Hide extensions for known files types”. This is a number 1 security issue to prevent viruses. If you know the extension is a possible virus you can more easily avoid it.

  • Now reboot your PC (Start | Shutdown | Restart). Ignore any warnings that appear during the boot process.

While removing items that get into the way of optimizing your defragmentation process I would suggest that you temporarily remove the “hibernate” setting. This setting only applies to Windows ME, 2000 and XP. If you use hibernate, a part of the hard drive the exact same size as the amount of RAM you have is reserved. By turning this off before your defragment you will allow the computer to optimize all of the software into a proper order. Just remember to turn hibernate back on when you have finished defragmenting.

To remove the hibernation mode go to “Start | Settings (skip setting if you have XP) | Control Panel”.

  • Double click on “Power Options” and then select the “Hibernate” tab.
  • Remove the checkmark next to the “Enable hibernate support” check box, unless there is not one already in the box.
  • Next you will need to reboot your computer for this to take effect.

Now defragment your computer, it will be more thorough than ever. After rebooting defragment the computer and then turn virtual memory and hibernation back on!

Well, that concludes this week’s edition of The Weekly Geek, congratulations on a job well done. I hope these little walk throughs are making a positive improvement on you computer and your computing experience. Next week we are going to cover how to manually clean up your hard drive, until then, have a Worm free week

Tags: Hard Drives · Optimizing · Software · Speeding Up