Reputation: 13267
I've been writing utilities and mapping them to context menus via the Regedit on the Shell key of *, but I can't figure out how to make submenus like some of the more popular utilities do.
For example, if I have three scripts to move and rename files to three different folders, right now I have three different context menu entries. I'd prefer to have one called "move and rename..." that expands to those three.
Upvotes: 5
Views: 8057
Reputation: 1166
You can specify group/menu name with subcommands and specify items, for example - to make context menu for EXE file
group name: "InstallShield debug"
group subcommands:InstDbg1;InstDbg2;InstDbg3;InstDbg4;InstDbg5;InstDbg6;InstDbg7
group item1: name: "debug installer /d" ; key InstDbg1
group item2: name: "debug installer /d /v..." ; key InstDbg2
etc
the reg file for this would be
Windows Registry Editor Version 5.00
;cascading context menu - use empty lines between registry items
;separator before: "CommandFlags"=dword:00000020
;SubCommands contains keys to be found in the registry - should match
KEY_CLASSES_ROOT\exefile\shell\InstallShield cascade menu]
"MUIVerb"="InstallShield debug"
"Icon"="C:\\Program Files (x86)\\InstallShield\\2020\\System\\isdev.exe"
"SubCommands"="InstDbg1;InstDbg2;InstDbg3;InstDbg4;InstDbg5;InstDbg6;InstDbg7"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg1]
@=""
"MUIVerb"="debug installer /d"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg1\command]
@="\"%1\" /d"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg2]
@=""
"MUIVerb"="debug installer /d /v TEST_STATUS=Good"
"CommandFlags"=dword:00000020
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg2\command]
@="\"%1\" /d /v\"TEST_STATUS=Good\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg3]
@=""
"MUIVerb"="debug installer /d /v TEST_STATUS=Undetermined"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg3\command]
@="\"%1\" /d /v\"TEST_STATUS=Undetermined\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg4]
@=""
"MUIVerb"="debug installer /d /v TEST_STATUS=Unauthorized"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg4\command]
@="\"%1\" /d /v\"TEST_STATUS=Unauthorized\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg5]
@=""
"MUIVerb"="run installer /v TEST_STATUS=Good"
"CommandFlags"=dword:00000020
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg5\command]
@="\"%1\" /v\"TEST_STATUS=Good\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg6]
@=""
"MUIVerb"="run installer /v TEST_STATUS=Undetermined"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg6\command]
@="\"%1\" /v\"TEST_STATUS=Undetermined\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg7]
@=""
"MUIVerb"="run installer /v TEST_STATUS=Unauthorized"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg7\command]
@="\"%1\" /v\"TEST_STATUS=Unauthorized\""
Upvotes: 2
Reputation: 564
You can create a submenu to context menus via registry, WIN 7 as seen here
Backup your registry first is recommended!
This example puts a submenu with a single command into the rightclick context on any file (not folders or desktop).
The menu:
[HKEY_CLASSES_ROOT\*\shell\Custom Menu]
"MUIVerb"="Custom Tools"
"SubCommands"="Custom.copytoclip"
The commands:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Custom.copytoclip]
@="copytoclip description here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Custom.copytoclip\command]
@="cmd /c clip < %1"
Please be careful editing your registry, other versions of windows may work differently.
Upvotes: 6
Reputation: 38825
You haven't specified what language you are using. Anyway, what you need to do is write a Shell Extension. There'a a guide, here.
As David has pointed out, it is not possible to do this in C# This blog post explains it.
Upvotes: -1