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.
Add Defragment Option to Right-click Menu
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.
In the Registry Editor, navigate to the following location:
Once there, right-click on the “Shell” key, select the option “New” and then “Key.”
Name the new key
runas and press the Enter button. After you create the key, this is how it will look.
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.
Once you are done setting up the value data, this is how it looks in the Registry Editor.
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.”
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.
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.”
Name the new key as “command,” and press the Enter button to save the changes.
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.
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.”
Since we used the verbose switch (
-v), you can see all the details in the command window as Windows defragments the selected drive.
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.