Kae Travis

Add a Right-click Context Sub Menu

I’ve been creating a few tools recently for a client – scripted tools which perform specific tasks on MSI (Windows Installer) files. Because we’re likely to create multiple tools and I don’t want the context menu to get too long and too ugly, so I decided to add a right-click context sub menu.  Here’s what it produces:

context

And here’s the registry that made it happen:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Msi.Package\Shell\AlkaneTools]
"MUIVerb"="Alkane Tools"
"SubCommands"="CustomTool1;"
"icon"="\\\\server\\pathtoicons\\alkane.ico"
"Position"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\CustomTool1]
@="Custom Tool 1"
"icon"="\\\\server\\pathtoicons\\alkane.ico"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\CustomTool1\command]
@="mshta.exe \"\\\\server\\pathtotools\\mycustomtool.hta\" \"%1\""

If you look closely, you should see that this context menu will only show for MSI files because we use the Msi.Package progid.  You’ll also note that when we export registry into a .reg file like above, all quotes in the registry values are escaped by a preceeding backslash as indeed are all backslashes!  So a quote would be \” and a backslash would be \\!  As an example (taken from above) the value:

mshta.exe \”\\\\server\\pathtotools\\mycustomtool.hta\” \”%1\”

when imported will resolve to:

mshta.exe “\\server\pathtotools\mycustomtool.hta” “%1”

 

Add a Right-click Context Sub Menu
Add a Right-click Context Sub Menu

2 thoughts on “Add a Right-click Context Sub Menu

  1. I was looking for something like this!

    Is there a way to apply this on every item you can right click on.
    For example:
    – right click on any file (.exe,  .bat,  .docx,  shortcut (lnk) etc…)
    – right click on any folder
    – right click on empty space on desktop

    Thank you.

     

     

     

    • Hi. Glad you found it useful. You might want to check this article out – it’s probably a little more in depth than my blog when describing the various options you require.

Leave a Reply to Kae Cancel reply