u/v32modem

How does assoc/ftype work with $args?

Hello.

I have a script that relies on args to pull in a file to edit:

$path = args[0]
$file_stream = [System.IO.File]::OpenRead($path)
# etc

I compiled this script into an .exe, and would like this to be associated with the filetype so that I can simply open it up in the Powershell script .exe that does the task.

I used assoc and ftype to associate the file extension with the created .exe. However, it seems to not work with "Open with..." and/or opening the file with Explorer. The script does work as intended in the case that I launch it within a Powershell instance or simply drag the file into the exe.

So my question is, if the $args are still working when dragging, what is going on under the hood with assoc/ftype and "Open with..." that I need to adjust within the script before compiling again?

reddit.com
u/v32modem — 3 days ago