- Worldstart's Tech Tips And Computer Help - http://www.worldstart.com -

Add Defragment to the Right Click Context Menu

Kaleen writes:

I really try to take care of my computer and use defragment a lot. I don’t know if it’s possible, but can I add it to the right-click menu? I use Vista.

First let me say that I think it’s awesome that you defragment your computer a lot. One of the things I learned when I got my first computer was to defragment, and it was great advice.

Yes, you can add defragment to your right-click (context) menu. It does involve editing the registry a little, so make sure you back up your registry before you start. Things that happen in the registry cannot be undone and can wreak total havoc your system. Click here [1] to learn how to back up your registry.

Note: If you would like to learn more on navigating the registry, click here [2].

Make sure you go through this with me exactly, that way you won’t make your computer upset and you a basket-case. But, since you started by backing up the registry, if you do make a mistake, you have a way to restore your original settings. Which you won’t do, because I won’t let you! Here we go:

The first thing you always do when you are going to edit the registry is left-click on your Start menu, and then go to your Run line. If you have the regular Start menu enabled, then you will see the Run line at the bottom of the right-hand side. If your start menu doesn’t show the Run line, click here [3] for an article on how to add it to the menu. If you have the Classic menu enabled, then the Run line should appear above your Shut down option in the Start menu, right above the Start button.

To access Run in with the regular Start menu:

To access Run with the Classic menu:

Note: After you have accessed Run, everything is the same in both menus.

If you would rather use a keyboard shortcut, just type Win + R (Win being your Windows key) and your Run box will pop up.

After you have left-clicked on Run, a text box will appear next to it. Type regedit in the box (to the right of Open) and left-click on OK.

One final way to get to the registry editor is to type regedit into the Search box, wait a second, and then regedit.exe will appear at the very top. Left-click on it to open it.

You are now looking at your Registry Editor.

What we are going to do now is navigate to the place where we want to edit the registry. This is where we want to navigate to:


You will see that the editor has two panes. In the left pane, you will see Computer, and under it, you will see HKEY_CLASSES_ROOT. Left-click on that to highlight it, and then point your cursor at the little plus sign to the left and left-click on it to expand a drop-down menu.

After you click on the little plus sign, a new menu will drop down. Go down the menu until you see Drive and then left-click on the little plus-sign next to that.

A menu will drop down again. Go down the list until you see shell. Left-click on it to highlight it.

Now we’re going to edit the registry; this time we will be working in the right pane, as well as the left pane.

The first thing we’re going to do is right-click on shell. On the menu that pops up, point your cursor on New to highlight it, and then left-click on Key.

A place to name the key will appear in the left pane. We have to name the key, so in the area to the left that is now highlighted, type in runas.

After we create the runas key, we need to change the Default value (right pane) and name it Defragment. To change the default value, right-click the Default key and then left-click on Modify. A text box will pop up; type Defragment in it, then left-click on OK.

Whew! Seems like it’ll never end, huh? We’re almost done.

Now we’re going to create the final key. Right-click runas, point your cursor at New to highlight it, and then left-click on Key. When the text box pops up, so that you can name it, type command in the box.

Then name the key command:

As we did before, we have to change the Default value. Right-click on Default and then left-click on Modify. In the text box that pops up, type this in:

defrag %1 –v

Left-click on OK.

Close out the Registry Editor.

To see the final result, go to My Computer and left-click, and then right-click on your hard drive (the C: drive).

Here’s the before and after.

Now no more left-clicking and left-clicking and pointing to Accessories and and and … Now you can just right-click to defragment your hard drive whenever you feel like it. And that’s a good thing!

Thanks for writing, Kaleen!

~ Lori Cline