How can I set up a context menu for a program on Windows (such as Sublime Merge)?

  • Page Owner: Not Set
  • Last Reviewed: 2018-10-23

Sublime Merge doesn't automatically add a Windows Explorer context menu, but I'd like to have one. How can I add a context menu item for this, or other programs?


Answer

Adding context items to Windows explorer is as simple as editing the registry. You'll need to add entries under HKEY_CLASSES_ROOT\Directory\shell\ for when you right click on a folder, and HKEY_CLASSES_ROOT\Directory\Background\shell\ for when you click the empty space inside a folder.

Both places will need a MUIVerb string value, optionally an Icon string, and a command key with a default value pointing to the path of the program and %v to represent the path of the right-clicked directory.

See below for an example .reg file that will add Sublime Merge to Explorer, but this should work with any other program that deals with folders.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Shell]
@="none"
[HKEY_CLASSES_ROOT\Directory\shell\SublimeMerge]
"Icon"="C:\\Program Files\\Sublime Merge\\sublime_merge.exe"
"MUIVerb"="Sublime Merge"
[HKEY_CLASSES_ROOT\Directory\shell\SublimeMerge\command] 
@="C:\\Program Files\\Sublime Merge\\sublime_merge.exe %v"
[HKEY_CLASSES_ROOT\Directory\Background\shell\SublimeMerge]
"Icon"="C:\\Program Files\\Sublime Merge\\sublime_merge.exe"
"MUIVerb"="Sublime Merge"
[HKEY_CLASSES_ROOT\Directory\Background\shell\SublimeMerge\command]
@="C:\\Program Files\\Sublime Merge\\sublime_merge.exe %v"

Comments

  • On a related side-note, you can also Alias sublime-merge in Powershell, since it doesn't appear to be added to the path by default: Set-Alias smerge 'C:\Program Files\Sublime Merge\sublime_merge.exe'