2

I've added a Windows right-click menu item by adding registry keys to HKCR\*\shell, where the command is of the form "path\to\my\program.exe" "params before" "%1" "params after". It seems that, if the user right-clicks on a shortcut (.lnk file), Windows is resolving the shortcut and passing the target file's path in as %1. Does anyone know where this is documented? This is used on Windows 7 and Windows XP machines.

Thanks!

Lesmana
  • 25,663
  • 9
  • 82
  • 87
Becca Dee
  • 1,530
  • 1
  • 24
  • 51
  • 1
    [Which special variables are available when writing a shell command for a context menu](https://superuser.com/a/473602/376602). – JosefZ Dec 13 '19 at 14:43
  • Thanks for the unexpected but clarifying comment, @JosefZ! It's amazing how these old questions still get found, so hopefully the next person will find this useful. – Becca Dee Dec 18 '19 at 18:44

1 Answers1

1

I don't know if it is documented anywhere but it makes sense if you think about it. 99% of the time you want to see the context menu for the target, for a batch file for example it will show the (default) open verb and the edit verb. If the shortcut implementation did not do this then the context menu would be pretty useless since it would only contain commands related to the .lnk file (Cut, Copy, Delete and Properties)

If you also register a verb under HKEY_CLASSES_ROOT\lnkfile\Shell, that verb should have the path to the .lnk when executed.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • Thanks for the additional information. I agree that it makes sense to show the context menu for the target. – Becca Dee Feb 14 '12 at 16:39