How to Defragment Your Hard Drives from The Context Menu in Windows

If you are using a regular hard drive with a spinning disk, over time it may get cluttered and fragmented. This fragmentation reduces the responsiveness of the hard disk. This is especially true if you are using the hard disk for a long time without defragmenting. To deal with this, Windows automatically defragments your hard drive once a week when you are not using your computer. Of course, it doesn’t defragment your SSD as it doesn’t need it.

However, the scheduled task to defragment the drive misses from time to time. If you want to manually defragment your drive, you need to dig through the Control Panel. To make things a bit easier, you can add the defragment option to the right-click context menu on a drive. Here’s how to do so.

Note: before making any changes to the Windows Registry Editor, make sure that you have a good backup. It helps you roll back if anything bad happens in the process of editing.

To add the defragment option to the right-click context menu, we are going to create a couple of new registry keys. To start, press “Win + R,” type regedit and press the Enter button to open the Windows Registry Editor. Alternatively, you can also search for the Registry Editor in the Start Menu.

add-defragment-option-win10-regedit-run-command

In the Registry Editor, navigate to the following location:

HKEY_CLASSES_ROOT\Drive\shell

add-defragment-option-win10-navigate-to-key

Once there, right-click on the “Shell” key, select the option “New” and then “Key.”

add-defragment-option-win10-select-option-new-key-1

Name the new key runas and press the Enter button. After you create the key, this is how it will look.

add-defragment-option-win10-key-created-1

On the right panel you will see a default string value with the name “Default.” By default, this value doesn’t have any value data. To set the value data, double-click on it. Here, enter the value data as Defragment and click on the OK button. This is the value that appears when you right-click on the drive. If you want to, you can customize this value to whatever word you want.

add-defragment-option-win10-enter-value-data-defragment

Once you are done setting up the value data, this is how it looks in the Registry Editor.

add-defragment-option-win10-value-data-added

If you want the defragment option to only appear when you “Shift” + right-click, then you need to create a new string value. Right-click on the empty space, and select the option “New -> String Value.”

add-defragment-option-win10-select-string-value-1

Now, name the new value as “Extended,” and press the Enter button. There is no need to add any value data for this value. Just continue to the next step.

add-defragment-option-win10-create-extended-value

We need to create another key to complete the procedure. Right-click on the “runas” key we created earlier, and select the option “New -> Key.”

add-defragment-option-win10-select-option-new-key-2

Name the new key as “command,” and press the Enter button to save the changes.

add-defragment-option-win10-key-created-2

Select the newly-created key and double-click on the “Default” value appearing on the right panel. In the Edit Value window enter the value data as defrag %1 -v and click on the “OK” button to save the changes.

add-defragment-option-win10-enter-value-data-command

You’ve successfully added the defragment option to the right-click context menu. Just restart your system or sign out and sign in to see the changes.

You can now defragment your drive by simply right-clicking and selecting the option “Defragment.”

add-defragment-option-win10-defragment-option-added

Since we used the verbose switch (-v), you can see all the details in the command window as Windows defragments the selected drive.

add-defragment-option-win10-defragment-running

Do comment below sharing your thoughts and experiences about using the above method to add the defragment option to the right-click context menu in Windows.

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.