Jameser's Tech Tips

Wednesday, July 19, 2006

Tip #22: Creating Context Menus for Explorer in Windows XP

Today's tip is on creating context menus for all file types in Windows Explorer... This will allow you to run any program on your PC against the file or files you have selected in Explorer... The example we'll be using today will use Notepad as the target application, but you can use any application you choose... Tomorrow's tip will apply these context menus towards a more practical purpose...

Open regedit(Start/Run/regedit)... If you haven't backed up your registry in a while, you should probably do that now... To back up your registry, simply select File/Export from the menu bar... Make certain that the "Export Range" at the bottom of the Export Registry File window is checked on "All", then select a filename to save your registry to... A good choice is the date you're backing it up, (i.e. 2006-06-29.reg)...


Now that we've backed up our registry, we'll need to expand HKEY_CLASSES_ROOT... We're looking for the folder labeled "*", which should be the first subfolder listed... The "*" is a wildcard that matches all file extensions... Click the "plus" next to the "*" folder to expand it... If you see a subfolder under "*" labeled shell, not shellex but shell, you can skip to the next paragraph... If you don't have the shell key, we'll create it now by right-clicking on the "*" folder and selecting New/Key from the menu... Name the new key shell...


Now, with our new shell key, we'll need to add another key for our context menu... Right-click on the shell folder, and select New/Key... Give this key a meaningful name for our context menu, such as opennotepad...


Next, single click on opennotepad (or whatever you named this key)... In the right-hand pane, you should see the default string labeled (Default)... Double-click on this (Default) string... In the Edit String dialog, give the title for this context menu as you'd like it to appear when a file is right-clicked... I'll use "Open With Notepad"...


Now, we need to let the system know what program we'd like to execute when our context menu is selected... Right-click on your "opennotepad" subkey, and select New/Key... Name this new key Command...


Now single-click on the new Command subkey so that it is highlighted... Then double-click on the (Default) string in the right hand pane... In the Value data field, enter the name of the command you'd like to run when this item is selected from your context menu... We'll use notepad.exe %1... The %1 is the filename of the file you're right-clicking on in Explorer...


Finally, test your new context menu by right-clicking on any file in Windows Explorer... You should now have a context menu item entitled "Open With Notepad" (or whatever you named yours) and it will launch the file in Notepad if selected...


Please leave a comment if you have any questions, and check back tomorrow for all new tips...

3 Comments:

  • At 9/20/2006 8:45 AM, Anonymous Anonymous said…

    Just what I needed, thanks

     
  • At 10/21/2006 11:09 AM, Anonymous Anonymous said…

    Hey, and thanks for the great advice.
    However I need some help.

    When I want to put several files in a playslist in Windows Media Player I usually just right click and select play with windows media player in the context menu. But that option dosent show up when I right click other formats than .mp3 and .wmv.

    Do you know how to make the functions of the context menu that exists for .mp3 and .wmv also work for other formats such as .ogg .acc and .ape?

     
  • At 4/15/2008 3:43 PM, Anonymous Anonymous said…

    Hey, thanx this is pretty cool!

    but i need another use for my new context menu, is there a list of commands to use for different stuff?

    or how can i know what the code i type in would be?

    i want to load the file i click on to an ftp site

     

Post a Comment

<< Home