Search code examples
windowscopycontextmenu

Getting the selected files path from a custom application in context menu


I have a scenario where I keep copying a bunch of files to same folder and if it exists, I rename the original file there and copy the files. I want to automate this process. I was checking if I can add a context menu option which shows on right-click in Windows. I followed few tutorials which had gave me a way to add a program to the context menu by modifying regkeys. But that just starts the program, I wanted to know how to get the paths of the items selected for copy to. Is there a way to achieve this? Or am I going down a wrong path?

I have added this command to context menu with my programs exe as value.

enter image description here

I want to know how to get the paths of selected items in my program.

enter image description here


Solution

  • I found the answer for this. When adding regkey for the context menu command specify it as following "PathToExe.exe""%1". This passes the selected folder/file full as the first argument