Solution edit: after a lot of googling and troubleshooting, I ended up looking at the Powershell and cmd regedit commands since the address was always pulled into those editors when run from the context menu. I saw both used "%V" at the end of their paths so I typed my command as I would in Powershell or cmd and put: "<the name of my path>" %V into the data field of my key (exact text: "C:\Work\resizing.exe" %V). This command exectued exactly as desired!
Helpful links I found regarding regedit:
- https://support.microsoft.com/en-us/topic/how-to-add-modify-or-delete-registry-subkeys-and-values-by-using-a-reg-file-9c7f37cf-a5e9-e1cd-c4fa-2a26218a1a23#bkmk_syntax
- https://www.tenforums.com/tutorials/121855-edit-user-system-environment-variables-windows.html
- How add context menu item to Windows Explorer for folders
- https://en.wikipedia.org/wiki/Windows_Registry#Registry_editors
I have a Python script that takes in the address of a folder and resizes all the images in that folder. I have made this script into an executable file that successfully runs when I put it through the command line, passing the address in as a parameter.
I would really like to add this code to the context menu so I'm able to right-click a folder and run my script on it. I've added the .exe file to the context menu through regedit in HKEY_CLASSES_ROOT\Directory\shell and can view the command in my context menu, but when I run it on a folder nothing happens. I'm assuming this is because I am not correctly passing arguments to my file.
In my code I use sys.argv[1] to access the address parameter. I'm not sure if I should have something different to get the desired address parameter from regedit or if I should be adding something to the data of my "command" subkey other than the address of my .exe file.
Any help would be greatly appreciated, I'm not particularly familiar with regedit!