Right-click “Open” with arguments

不问归期 提交于 2020-01-19 17:41:07

问题


I would like to add an entry to the Windows right-click menu that only appears when I right click on a .exe or .msi file. If the entry is selected, the exe file will be executed (like Open) but with a fixed text string as its argument.

I guess this should be possible with a registry key - any ideas how to do this?


回答1:


For an .exe file, you can do the following in the registry:

  1. Under HKEY_Classes_Root, find key .exe
  2. Read the (Default) value (this is usually exefile)
  3. Under HKEY_Classes_Root, find key exefile (or whatever you found in step 2)
  4. Under exefile\shell create a new key, with a name matching what you want to see in the context menu (say, "Open With My App")
  5. Under your new key, create a new key called command
  6. Set the (Default) value of this key to whatever commandline you want to execute. The name of the file you clicked on can be entered using the token %1. So, for example, you could set the value to notepad.exe %1 to edit the executable in Notepad.

A similar pattern will work for other file types.




回答2:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.exe\shell\Copy Address\command]
@="C:\\Windows\\CopyAddress.exe %1 "

[HKEY_CLASSES_ROOT\.msi\shell\Copy Address\command]
@="C:\\Windows\\CopyAddress.exe %1 "

Change path and menu name(CopyAddress) as per your choice.



来源:https://stackoverflow.com/questions/11881938/right-click-open-with-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!