Hack 29 A Power User's Hidden Weapon: Improve the Context Menu


The context menu is an often underused tool. But with these four additions and edits to the menu, it'll turn into a powerhouse that you'll use every day.

Windows Explorer's right-click context menu is one of the most basic of all XP tools; it provides many shortcuts for whenever you want to take action on a file or a folder. But the right-click menu is missing several basic options, such as choosing a specific folder to which you want to move or copy the file you've highlighted, rather than just cutting or copying the file. And when you install new applications, they have a nasty habit of adding their own options that you'll rarely use in the right-click menu.

The end result: a right-click context menu cluttered with options and lacking several basic useful ones. But you can extend the power of the menu with these four hacks.

3.10.1 Add "Copy To Folder" and "Move To Folder" Context Menu Options

I spend a lot of time copying and moving files between folders. More often than not, when I click on a file in Explorer, I want to copy or move it to another folder. That means I spend a good deal of time dragging files around or copying and pasting them.

But with a Registry hack, you can save yourself time: you can add Copy To Folder and Move To Folder options to the right-click context menu. When you choose one of the options from the menu, you browse to any place on your hard disk to copy or move the file to, and then send the file there. To add the option, run the Registry Editor [Hack #68] and go to HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers. shellex tells you it's a shell extension key that lets you customize the user shell or the interface. Create a new key called Copy To. Set the value to {C2FBB630-2971-11d1-A18C-00C04FD75D13}. Create another new key called Move To. Set the value to {C2FBB631-2971-11d1-A18C-00C04FD75D13}. Exit the Registry. The changes should take effect immediately. The Copy To Folder and Move To Folder options will appear. When you right-click on a file and choose one of the options, you'll be able to move or copy the file using a dialog box like the one shown in Figure 3-20.

Figure 3-20. Specifying a destination using the Copy To Folder option

3.10.2 Add and Remove Destinations for the "Send To" Option

The right-click context menu does have one useful option, Send To, which allows you to send the file to any one of a list of programs or locations?for example, to a drive, program, or folder.

It would be nice to edit that list, adding new locations and programs and taking away existing ones that you never use. How locations and programs show up on the menu appears to be somewhat of a mystery, but, in fact, it's easy to hack. Go to C:\Documents and Settings\<User Name>\SendTo, where <User Name> is your user name. The folder will be filled with shortcuts to all the locations you find on your Send To context menu. To remove an item from the Send To menu, delete the shortcut from the folder. To add an item to the menu, add a shortcut to the folder by highlighting the folder, choosing File New Shortcut, and following the instructions for creating a shortcut. The new setting will take effect immediately; you don't have to exit Windows Explorer for it to go into effect.

3.10.3 Open the Command Prompt from the Right-Click Menu

I began computing in the days of DOS, and I still can't give up the command prompt. When it comes to doing down-and-dirty tasks like mass deleting or renaming of files, nothing beats it. I find myself frequently switching back and forth between Windows Explorer and the command prompt.

Often, when using Windows Explorer, I want to open the command prompt at the folder that's my current location. That takes too many steps: opening a command prompt and then navigating to my current folder. However, there's a quicker way: add an option to the right-click context menu that will open a command prompt at your current folder. For example, if you were to right-click on the C:\My Stuff folder, you could then choose to open a command prompt at C:\My Stuff.

To add the option, run the Registry Editor [Hack #68], then go to HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell. Create a new key called Command Prompt. For the default value, enter whatever text you want to appear when you right-click on a folder?for example, Open Command Prompt. Create a new key beneath the Command Prompt key called Command. Set the default value to Cmd.exe /k pushd %L. That value will launch Cmd.exe, which is the XP command prompt. The /k switch puts the prompt into interactive mode. That is, it lets you issue commands from the command prompt; the command prompt isn't being used to issue only a single command and then exit. The pushd command stores the name of the current directory, and %L uses that name to start the command prompt at it. Exit the Registry. The new menu option will show up immediately. Note that it won't appear when you right-click on a file; it shows up only when you right-click on a folder.

While many of us like fussing around with the Registry rather than doing things the easy way, there's also a way to add this option to your right-click context menu without editing the Registry. Download and install a free copy of Microsoft's "Open Command Window Here" PowerToy from http://www.microsoft.com/windowsxp/pro/downloads/powertoys.asp. There are many other PowerToys on that page as well, and we cover them in other places in the book.

3.10.4 Clean Up the "Open With" Option

When you right-click on a file, one of the menu options is Open With, which provides a list of programs for you to open the file with. This list changes according to the type of file you're clicking. Depending on the file type, the lists can get long, because programs frequently add themselves to this list when you install them. Making things worse, there are times when the listed programs aren't applicable. For example, do you really want to open a .bmp bitmap graphics file with Microsoft Word? I think not.

You can clean up the Open With list by using a Registry hack. Run the Registry Editor and go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts. Look for the file extension whose Open With list you want to edit and find its OpenWithList subkey?HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithList, for example. The subkey will have an alphabetical list of String values. Open each value and examine the value data. It will be the name of one of the programs on the Open With list (Winword.exe, for example). Delete any entry you don't want to appear. Don't delete the value data; delete the String value listing. In other words, if the value data for the a String value is Winword.exe, delete the entire string rather than just the value data. Exit the Registry.