Subscribe to How-To Geek

Add Defragment to the Right-Click Menu for a Drive

After writing the article last week about how to add Disk Cleanup to the context menu for a drive, I received several requests for how to add another menu item for Defrag instead. With a simple registry hack we can do just that.

After manually applying or downloading the hack, you’ll have a new item on the right-click menu for your drives…

image

Which will start up the command-line version of Disk Defragmenter (after accepting the UAC prompt)

image 

Manual Registry Hack

Open up regedit.exe through the start menu search or run box, and then browse down to the following key:

HKEY_CLASSES_ROOT\Drive\shell

image

Create a new key under shell called “runas”, and then set the (Default) value to “Defragment”. If you want to hide this menu item behind the Shift key right-click menu, then add a new string called Extended with no value.

image

Next, you’ll need to create a key called “command” and set the default value to the following, which is the command to run defrag with the default options but show verbose output.

defrag %1 -v

You can alternately choose from one of the other defrag switches here if you’d like.

Downloadable Registry Hack

Simply download, extract, and double-click on either AddDefragToDriveMenu.reg (for the regular menu) or AddDefragToExtendedDriveMenu.reg (to hide behind the Shift key). There’s also an included removal script that will remove either one.

Download AddDefragToDriveMenu Registry Hack

The Geek is the founder of How-To Geek and a geek enthusiast. This article was written on 06/25/08 and tagged with: Vista Tips & Tweaks, Windows Vista

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:
Similar Articles Featured Wiki Articles
Latest Software Reviews Quick Linux Tips
Geek Arcade Popular Forum Threads

Comments (13)

  1. USBman

    As one of those that requested this tweak, I humbly thank you.

    Adding the “runas” piece overcame the administrator requirement, and the “Extended” string is a nice touch (works for the aforementioned previous post on adding Disk Cleanup too!).

    Overall, the kind of elegant solution I’ve come to expect from your site. Well done.

  2. The Geek

    Glad I could help! =)

  3. Brian

    I sure wanted to try this but without the download.
    Since I have only minimal registry work I was careful to do exactly as you had posted.

    However, when I select defragmenet I get
    “Which user account do you want to run this program.”
    I then selected current user.
    But then I get just a flash of the DOS screen and it disappears.

    I have double checked all the registry entries and they look just like the ones you posted. Any idea what I can do to keep the DOS screen from disappearing?

    BTW, I don’t have Vista, I am using XP 2nd Edition.

    THANKS

    BRIAN

  4. The Geek

    @Brian

    For XP, you should rename the runas key to something else, like just “defrag”. I need to update the post to explain the alternate XP instructions… thanks for mentioning.

  5. abhs94

    Hey Geek,
    This was really helpful
    how do you get to know about such tweaks

  6. Mike's beeps! Hahahahahahahahaha!

    You rock!

  7. MikeHigham

    You rock! Thanks!

  8. Mike Higham

    Could you please do one for Check Disk as well?

  9. The Geek

    @Mike

    Will get on that.

  10. Motor Mike

    Does this work for network drives as well?

  11. brandon

    hey thnx alot for the helpful little tweaks
    greatly appreciated

  12. Spacegold

    It’s a nice little trick and I would jump on it in a second if Vista did not employ automatic defrag every week. On the rare occasion when a person might need to defrag a specific disk, it is easily done from the control panel.

  13. bw

    I successfully implemented this reg hack, but the CMD prompt closes afterwards (automatically). Is there a way to have the CMD prompt stay open so I can review the results?

    Thanks Geek, not only for a great hack, but a great site.

    bw


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Sponsored Links
Getting Started
About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
Cmd.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. All Rights Reserved.