Hey everyone! I've got a script that takes a file path as an argument, specifically using `$args[0]` to open and edit the file. I've compiled this script into an executable and I'd like it to be associated with a file type so that I can easily open files with it directly. I used `assoc` and `ftype` to link the file extension to my new .exe, but I'm running into issues. It doesn't seem to work when I try to open the file with "Open with..." in Explorer. It works perfectly when I run it directly in PowerShell or when I drag the file onto the executable. So, I'm curious, what happens with the arguments in `assoc` and `ftype` when using "Open with...", and what should I change in my script or the commands before I compile it again?
3 Answers
Just to clarify, are you trying to have the .exe directly associated with `powershell.exe`? That might need tweaking depending on how you're invoking the script.
What command did you use to set the associations? It sounds like you might not be passing the parameters as you think because of how you set it up.
Make sure you've specified where in your association you want the file path to be injected. It doesn't automatically append it; you need to place it correctly within the command string.
Thanks for the tip! I'll check out the ftype documentation to see how I can adjust it.

You were right! I was using `ftype`, but I needed to include the parameters `%0` or `%1` for the file name in the command. I saw that in the ftype docs!