Open a file with an Powershell Studio generated exe and catch filename in variable?

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
stevens
Posts: 353
Joined: Wed Jun 15, 2016 2:26 am

Open a file with an Powershell Studio generated exe and catch filename in variable?

Post by stevens » Sun Jun 23, 2019 9:58 am

Hi,

In short: see below: I'd like to catch a filename by a PS generated exe in a variable, then do stuff with it.
Would appreciate your any input to make this work!

--full explanation---
I'd like to check 3 scenario's:
1.doubleclicking an (to Windows) unknown filetype (f.e. a mypicture.gimp which is linked to Gimp program, but not installed) would open an (by Ps Studio) generated exe that sees the .gimp, matches it to the Gimp program and then offers to install Gimp
In this scenario, I'd link the unknown filetypes to the own created .exe, which is pretty straight forward (adapting the xml)
2.same scenario as above, but when Windows would offer a program to open and I choose the own created exe, same scenario as above happens (offer to install Gimp)
3.right mouse button on any program shows option openwith 'MyExe', then I offer options with what it could open and offer to install (Gimp or whatever other options)
=> All 3 scenarios would require the exe to catch the filename in a variable, rest is easy of course (f.e. $file = Myfile.gimp, match .gimp to program Gimp and popup with question to install).
---

jvierra
Posts: 13992
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Open a file with an Powershell Studio generated exe and catch filename in variable?

Post by jvierra » Sun Jun 23, 2019 10:41 am

See:

cmd /c assoc /?
cmd /c ftype /?


Once you associate the extension with your EXE then will have the filename.

The only other legal way to do this is to write a shell extension that handles all unrecognized extensions and have it do what you ask.

Locked