How to Defragment Your Hard Drives From The Context Menu [Windows]

If you’re not familiar with defragmentation in Windows, you really need to learn about it as soon as possible. Soon enough, you’ll be wondering where it’s been all your life, especially with the new features that Windows 7 introduces, which allow the drive to consolidate its free space and run multiple times in one session to make sure that the drive remains free of fragmented files.

Normally, you start the defragmenter utility by going to your “Start” menu and navigating from there. Obviously, this might be inconvenient for you if you need to defragment frequently. You could have multiple hard drives or a RAID configuration. There are a number of different reasons why you would want a context menu for defragmenting hard drive when you right-click on one.

I conducted a small survey of computer users who neglect drive defragmentation. Why?

More than half of those people said that they’d prefer the utility to be more reachable. So, I came up with an answer for that. The following is a tutorial that teaches you how to put a context menu when right-clicking your drive that lets you defragment it:

1. Access the “Run” dialog on your computer by pressing “Start + R” on your keyboard.

2. Type “regedit” and press “Enter.”

3. Navigate to “HKEY_CLASSES_ROOT\Drive\Shell“. It’s going to be tough to sift through all that if you have as much junk on your computer as I do. Here’s where we are so far:

defrag-regedit-shell

4. Right-click on “shell”, click “New” and click “Key.” Label it “runas“. Your “shell” key should look like this, expanded

defrag-regedit-runas

5. Right-click the “(Default)” key and click “Modify”. Write “Defragment” under “value data.” Click “OK”.

6. Right-click on an empty space in the right side of the screen, navigate to “New”, and click “String value”. Name it “Extended”, but don’t give it a value.

7. Create a new key under “runas” just like how you created one in “shell”. Name it “command”. Here’s where we are so far:

defrag-regedit-runas2

8. Now, we’re going to edit the command subkey, so select it. Edit the “(Default)” key value to:

defrag %1 -v

You’re done! Here’s how your final product should look like.

defrag-regedit-final

Now, you need to restart your computer before the changes take place. Once restarted, you should see a context menu for defragmenting your hard drive when you right-click on it. Please note that you shouldn’t be editing your registry if you have no experience in doing it previously. It’s a rather meticulous library your operating system relies on, and if you mess something up by accident, your computer won’t forgive you easily. Try backing up the registry before you try any modifications, regardless of your previous experience.

Note: To properly use the defragment option in the context menu of your drive, right-click the drive while holding “Shift” on your keyboard.