none
Open file with Powershell which then reads filename and takes an action (suggests application to install) RRS feed

  • Question

  • Hi,

    I would like to be able to start an application which has no filetype assocation with Powershell then execute an action.
    F.e. I have an .XMind (mindmapping tool) file but no XMind installed, example file1.XMind

    Two options here:

    -When I doubleclick it, it will ask me with what it should open it, I 'd like to use a Powershell script to open, which reads filename file1.XMind, then I can take actions from there (f.e. autoinstall XMind AppV package)
    Didn't find a solution there.

    -Same option as above but with rightclicking it, choose "open with MySCript" (just a the option "Open With VSCode" exists)
    Found this article https://www.maketecheasier.com/add-open-powershell-here-option-context-menu-windows/ but can't create a registry item there (not allowed even as admin)

    Would appreciate your input to get me going.
    Thanks!

    J


    Jan Hoedt

    Friday, June 21, 2019 7:58 PM

Answers

  • Also there is this:

    cmd /c assoc /?

    and

    and'cmd /c ftype /?


    \_(ツ)_/

    • Marked as answer by janhoedt Monday, July 8, 2019 8:23 AM
    Friday, June 21, 2019 9:43 PM
    1. I have not tested this.
    2. I'm not sure that I would recommend doing this.
    3. If I were going to do this, I think that I would use a compiled .exe instead of Powershell so that I could fully control the user interface. 

    When you use the Windows explorer to double click a file that has no associated program, these keys are referenced to call OpenWith.exe with the file name being passed as an argument. 

    You would need to change the default value to invoke your .exe (or Powershell.exe with parameters to point to your script) along with the %1 to pass the file name.

    If your code determined that there was no software to install, then your code should call OpenWith.exe to mimic the default Windows behavior.  

     

    See also: https://superuser.com/questions/257941/how-do-i-associate-all-unknown-file-types-with-notepad


    • Edited by MotoX80 Sunday, June 23, 2019 3:24 PM
    • Marked as answer by janhoedt Monday, July 8, 2019 8:23 AM
    Sunday, June 23, 2019 3:23 PM

All replies

  • https://www.thewindowsclub.com/add-any-application-to-right-click-menu-in-windows-10

    https://blogs.technet.microsoft.com/windowsinternals/2017/10/25/windows-10-how-to-configure-file-associations-for-it-pros/

    Right click on file with your extension and select "Open With" then search for the program you want to associate with that extension.

    The extension is registered in Classes registry key as the extension name.


    \_(ツ)_/

    Friday, June 21, 2019 9:39 PM
  • Also there is this:

    cmd /c assoc /?

    and

    and'cmd /c ftype /?


    \_(ツ)_/

    • Marked as answer by janhoedt Monday, July 8, 2019 8:23 AM
    Friday, June 21, 2019 9:43 PM
  • Did found the exact two links also  :-)
    Should have mentioned that, so guess my question wasn't really clear.

    Opening unknown filetypes isn't the issue, it's triggering an action on exactly that filetype.

    Let me give an example: clicking file1.xmind on a computer without XMind should trigger an install of XMind.
    For that I should be able to open XMind with Powershell, read the .XMind extension, map that to the program XMind which then installs.

    Triggering the install isn't an issue, but opening with Powershell and having .XMind in a variable (which then matches with the program XMind) is actually my question.

    Thanks for any feedback!


    Jan Hoedt

    Saturday, June 22, 2019 7:00 AM
    1. I have not tested this.
    2. I'm not sure that I would recommend doing this.
    3. If I were going to do this, I think that I would use a compiled .exe instead of Powershell so that I could fully control the user interface. 

    When you use the Windows explorer to double click a file that has no associated program, these keys are referenced to call OpenWith.exe with the file name being passed as an argument. 

    You would need to change the default value to invoke your .exe (or Powershell.exe with parameters to point to your script) along with the %1 to pass the file name.

    If your code determined that there was no software to install, then your code should call OpenWith.exe to mimic the default Windows behavior.  

     

    See also: https://superuser.com/questions/257941/how-do-i-associate-all-unknown-file-types-with-notepad


    • Edited by MotoX80 Sunday, June 23, 2019 3:24 PM
    • Marked as answer by janhoedt Monday, July 8, 2019 8:23 AM
    Sunday, June 23, 2019 3:23 PM