What's the simplest way to just add a registry entry so your app has a context menu on right click

I remember I used to have a registry file that I would run and it would make my .exe avaiable when you right click on a tif file in a windows environment.
silentthread2kSenior Software EngineerAsked:
Who is Participating?
something like this?  This is for notepad but you can substitute your app
http://windowsxp.mvps.org/context_folders.htm gives all the possible registry locations.
Customizing Right-Click Menu Options in Windows
MikeIT ProfessionalCommented:
If you right click on the file, choose open with, and choose the program you want, you can have it open always with that program, or open once with that program.  Either way, once you do one of those, it will show up in the context menu under open with afterwards....
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

NikSystems SpecialistCommented:
Run Regedit
Navigate to HKEY_CLASSES_ROOT\Folder\shell
Add a new Key to the "Shell" Key and name it as you wish.
Give it a default value that will appear when you right click a folder, i.e. NewKey (use an "&" without the quotes, in front of any character and it will allow you to use the keyboard)
Click on the Key HKEY_CLASSES_ROOT\Folder\shell\NewKey
Add a New Key named Command
Set the (Default) value of the application you want to run
For example: c:\program files\internet explorer\iexplore.exe (Include the full path and parameters if you need them)
Hi silentthread2k

If you have several applications that you regularly use to view TIF files, but do not want to associate the TIF file extension to any of them other than what currently opens when you double-click a TIF file, then you should already have several programs listed on the Right-Click > "Open With" menu.

The new programs should be added to the list after you use the Right-Click > "Open With ..." > Select a Program from the list > Scroll to or "Browse" to a program executable > click OK.

Be sure to *** UNTICK *** the box in the "Open With" dialog entitled "Always use the selected program to open files of this type", OR ELSE the program you choose will become the program that opens when you double-click a TIF file.

Repeat this for all the programs that you sometimes have the need to open TIF files in, and your new "Open With" listing is as quick to get to as adding yet another item to what may already be a lengthy Right-Click menu.

Of course, doing this too often for different programs, especially when experimenting to see what programs can and cannot open a particular file type, will add clutter to your "Open With" menu.   Ramesh Srinivasan (same author as loki_loki's 2nd link in the comment above) explains how to clear out this unwanted clutter here:
He supplies a useful "File Extension Info" tool to help you with it here:
and yet another one that allows you to create your own entries here:

Remember that the Right-Click > "Preview" option for most image file types will open in the Windows Picture and Fax Viewer in Windows XP, so leave that in place if you are tempted to mess with 3rd party applications that thin out the "Open With" menu.

Some people (me included) like the Right-Click > "Open With" menu option, while some people don't.  It's a personal choice, as is the preference for any utilities to view and/or manage file extension properties.

My preference for viewing details of, and quickly opening regedit to the correct key for, file extensions, is "File Types Manager" by Nir Sofer (same author as the "ShellMenuView" and "ShellExView" utilities suggested in loki_loki's 2nd link):
Using that I can jump to the first relevant registry key.

A general rule of thumb and warning:

If the file type does not show, or shows but will not allow you to Edit it, in the Control panel > Folder Options > File Types dalog, then DON'T mess with it in Regedit, by merging reg files, or using 3rd party utilities.

Hope this helps


Read On If You Want To Know Some More Technical Info
(otherwise ignore everything below this).

What you should always remember is that a simple file type association exists in two main keys in your registry.  The first key is the one that shows the file extension with a dot, example:


The String value (REG_SZ) that shows in Regedit as (Default), or in an exported *.reg file as  @="string here", will be a common name that often reflects the actual file extension.  In the case of the *.TXT file, the (Default) string value is "txtfile".  That forms the basis of the OTHER key to scroll down and find:


In THIS key, the (Default) string value is usually a more descriptive expression that defines what this type of file comprises.  It is in this key that you find the actual program association in the form of  "Shell\Verb\Command", where the "Verb" is the name of the action that shows in the Right-Click menu.

For example, for the *.TXT file the default action is "Open", and the corresponding key containing the path to the executable and any command parameters is:


The action that shows in bold text in your Right-Click menu for that file type, and is therefore your "Double-Click" action, is dictated by the (Default) string value right in the "Shell" key.  In an exported REG file for the *.TXT extension set to Notepad, you would see this:

Windows Registry Editor Version 5.00

@="Text Document"


@="open" <--------------------------------*** Your Bold "Double-Click" action ***

@="Open in BillPad"

@="\"C:\\Program Files\\Billpad\\billpad.exe\" %1"


[HKEY_CLASSES_ROOT\txtfile\shell\open\command] <--- *** Corresponding "Open" Command





Open in new window

Note that my REG file contains an additional key:
that I added so that I have another action named "Open in BillPad" for all *.txt files.

Windows and a lot of more recent application installers create the actual program command as a "REG_EXPAND_SZ" (or expanded string value) in the registry.  This is what shows in lines starting with    @=hex(2):   in an exported REG file.  For most this is gobbledegook and not something you could easily look at and amend or edit, but in Regedit when you double-click on a REG_EXPAND_SZ value it allows you to see the text equivalent.

There is nothing wrong in Windows XP with creating the value for your command as a standard String value (REG_SZ) which would show as follows if exported to a REG file:

@="\"C:\\Program Files\\Billpad\\billpad.exe\" %1"

Note that the REG file encloses the entire value in " " and, because the path to billpad.exe was deliberately double-quoted to avoid any potential issues with the space in the "Program Files" folder, those additional " " inside the ones applied to the Regedit export need to be handled literally, each is preceded by a \
For each backslash designating folders in the path to be treated literally, an extra \ is added in front of them too.

The %1 part of the command is a replaceable variable that stores the path to the file you are telling the program to open from the right-click or double-click. Sometimes this is enclosed in its own separate " " and sometimes not.  If a new action you created doesn't work at first, check whether you have a "%1" or a %1 and remove or add the " " to test again.  That's a common thing that causes people to tear out their hair in frustration.

Going back to the earlier bond between the:
keys, you will no doubt notice a couple of value that should be explained.

As a REG File:
"Content Type"="text/plain"

As Shown in REGEDIT:
(Default)           REG_SZ      txtfile
ContentType    REG_SZ      text/plain
PerceivedType  REG_SZ      text

The (Default) value was discussed above when telling how to find the other key containing the actual file association settings.  ContentType and PerceivedType refer to the kind of content that a file of this type should contain, and the values are used in various ways including how to display such a file in a web browser.

There are some odd values under the OTHER key, eg for the *.txt file again:


EditFlags             REG_DWORD           0x00000000 (0)
BrowserFlags      REG_DWORD           0x00000000 (8)

The EditFlags value is used to place restrictions on what you can see and edit for this file type in the Control Panel > Folder Options > File Types dialog, and the BrowserFlags value tells it whether to prompt for a download or display the contents of a file with this extension inside the web browser.


If you have a *.REG file containing a REG_EXPAND_SZ value, shown with the   @=hex(2):   and want to see what that would be expanded to when read from the registry if you were to import it to your registry, I suggest creating a temporary bogus key in a copy of the REG file and merging that first.

Let's say you have the following in a REG file:


Open in new window

What I do is make a copy of the REG file, open that in Notepad, and change the key to this:
and leave the rest as it is.

When merged to the registry that new key is very easy to find (it sits at the top of the sub-keys when you open HKEY_CURRENT_USER), you can immediately see what the command is, and can delete the "_TEST1" registry key.
silentthread2kSenior Software EngineerAuthor Commented:
Note: If anyone notices that they don't have shell under HKEY_CLASSES_ROOT\*\, then just create the shell key as well.

I did just that, because I found that I did not have shell. I had ShellEx.  So just create shell if you don't have it.
What exactly did you add under the key:
after you created that key?  Just curious.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.