Search code examples
windowseventsregistry

How to add new items to right-click event on Folders and Files in Windows?


I did google couple of tutorials on google.

I am able to add right-click menu item to a FOLDER by doing this:

[HKEY_CLASSES_ROOT\Directory\shell\Command]
@="TestRightClick:"

[HKEY_CLASSES_ROOT\Directory\shell\Command\Command]
@="myExecutable.exe %L"

I need to add this to a FILE as well.

1) Where do I add it in the registry?

2) And how do I pass parameters to my executable in case if I am selecting multiple files?

Related:

How to pass in multiple file/folder paths via a rigth-click event(verb) to an executable?


Solution

    1. Files have context menus by extension. Add your Command registry keys to the appropriate extension or HKEY_CLASSES_ROOT\* to affect all files.
    2. You can use %1 to pass the filename to the application (much like you've indicated with %L above). If you select multiple files, each will be called separately, as if you right-clicked each one individually.

    I'm not aware of any easy way to pass multiple items from a right-click context menu to one executable instance.