Forum Discussion

wallby's avatar
wallby
Copper Contributor
Aug 24, 2022
Solved

How to prompt for program to open file with using powershell

Hello,

 

I know that..

 

 

Start-Process -FilePath <path to file>

 

 

.. opens the file at path to file, however is it possible to, instead of opening with the default program, open the prompt that would open if you would right click on that file and then press Open with -> Choose another app?

  • Answer was given here.. https://docs.microsoft.com/en-us/answers/questions/981421/how-to-prompt-for-program-to-open-file-with-using.html

     

    The answer..

     

    Use openwith.

     

    $ps = new-object System.Diagnostics.Process
    $ps.StartInfo.Filename = "openwith.exe"
    $ps.StartInfo.Arguments = "C:\temp\xxxxxxxx.txt"
    $ps.start()

     

     

     

2 Replies

  • farismalaeb's avatar
    farismalaeb
    Iron Contributor
    Thanks for sharing it back... I was waiting for the answer 🙂
  • wallby's avatar
    wallby
    Copper Contributor

    Answer was given here.. https://docs.microsoft.com/en-us/answers/questions/981421/how-to-prompt-for-program-to-open-file-with-using.html

     

    The answer..

     

    Use openwith.

     

    $ps = new-object System.Diagnostics.Process
    $ps.StartInfo.Filename = "openwith.exe"
    $ps.StartInfo.Arguments = "C:\temp\xxxxxxxx.txt"
    $ps.start()

     

     

     

Resources