Getting Executable for File Extension

Hello, is there a cmdlet to get the executable for handling a specific File-Type

e.g. c:\ …\Liebreofice\writer.exe for file.odt ?

& - works but I need the path to the executable, because I want to use specific commandline parameters

Thank you

Welcome to the forum. :wave:t4:

AFAIK there is no built in cmdlet to determine the file type association of a given extension.

What would you like to accomplish? There might be another/better way.

I create a draft file (*.odt) which should then be opened by libre-office and after editing the file should be moved and an pdf created and perhaps send by (hyla)-fax.


& file.odt
libre_office starts and the file can be edited - but the powershell script is not paused until libreoffice terminated.


Wow, that sounds like a workflow from the 90’s. :face_with_hand_over_mouth: Really? … fax? :face_with_raised_eyebrow:

That sounds like there is a lot of manual work involved. And since LibreOffice can export PDF files out of the box it might be a better option to use some Office internal automation instead of PowerShell.

Regardless of that - I still cannot see whatfor you need the path for the executable.

If that’s your issue you could simply add a loop checking for the process of LibreOffice and when the process is terminated you could continue your script. :man_shrugging:t4:

The Script should work on different PC - and the Path to Libreoffice ist not the same in every PC.
So I need the Name of the executable to look if the process terminated.

And yes - we use Fax, which works nice … and the script get’s a Patient and doctor ID and Fax or PDF as Parameter
The iDs are used to create the filename - an at the end to move the file to an archive - or to cancel the file and delete the draft

Testing, whether the created file ist writeable would be an option …
Invoke-Item doesn’t accept -WAIT and return nothing

Another option is to define ab Systemvarible “libreoffice” on each PC which points to the LO-Path

The executable name should be the same or similar regardless of where it’s installed. You could simply query for existing instances and store that. Then launch libre and a new query should reveal the new process (compared to the list before) that you can wait until it’s gone. Otherwise this question should really be “how to find the install location of libre office”

So we’re talking about a very heterogenous environment the script has to work on, right?

As far as I can remember has the name of the executable always been soffice because it started as “Star Office” once and kept the file name since then. :point_up_2:t4: :wink:

Please don’t get me wrong … I wasn’t complaining … I was wondering. :wink:

For me that sounds more and more like PowerShell isn’t the right tool for the job. :man_shrugging:t4:

Again … an Invoke-Item for the desired file, wait a few seconds for LibreOffice to start and then loop as long as the process “soffice” is running should do the trick, don’t you think?

Either you search for the file in the default locations C:\Program Files or C:\Program Files (x86) on the first run of the script and save the found path persistently on the computer - for example in the registry. Or you simply use the running process to get the info you’re after.

Get-Process soffice | Select-Object -Property Name, Path, CommandLine