How to change "OpenWith" user preference settings from cmdline?

Discussion in 'Windows 7 Help and Support' started by pstein, May 13, 2015.

  1. pstein

    pstein Honorable Member

    Joined:
    Mar 20, 2010
    Messages:
    347
    Likes Received:
    0
    As you know some file may be opened by multiple installed programs.

    Assume I have 3 picture viewers installed for viewing *.jpg files.

    Currently the default program for opening these *.jpg is "aaa.exe"

    In the future I want to let the *.jpg open (by double clicking in Windows Explorer) by a second program bbb.exe

    Associating *.jpg extension with assoc and ftype does not help.
    UserChoice has higher priority than default association.

    So I need a way to modify the "OpenWith" User Preference as well.

    I want such a modification by command line command and not by clicking through GUI.
    Keep in mind that in reality I have to do this for a dozend of extension every time.

    Putting commands in batch script would be helpful.

    So again: How do I modify the "OpenWith" user preferences for lets say extension *.jpg to program bbb.exe from cmdline?

    thank you
    Peter
     
  2. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,018
    Likes Received:
    125
    To view/change associations via command line you'll need to look at assoc, and ftype commands.

    For instance to create a new association and file type...
    assoc .mytext=MyText
    ftype MyText=notepad.exe %1 %*
     
  3. pstein

    pstein Honorable Member

    Joined:
    Mar 20, 2010
    Messages:
    347
    Likes Received:
    0
    @Josephur:

    Please, read my initial posting carefully. I said that assoc and ftype does NOT help.
    Thats because these commands have LOWER priority than User customized OpenWith preferences.

    Thats exactly the reason why I want to change OpenWidth preferences and NOT the default ones.
     
  4. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,018
    Likes Received:
    125
    Ah yes I missed that bit, you are correct that user defined classes stored at HKEY_CURRENT_USER\Software\Classes will override this.
    Therefore I would suggest using the command line "reg add" and "reg delete" to modify keys in that area (or possibly just nuking the association in there and then using ftype and assoc)
     
  5. pstein

    pstein Honorable Member

    Joined:
    Mar 20, 2010
    Messages:
    347
    Likes Received:
    0
    Ok, thank you.

    Is nuking directly in registry really the only way?

    Is there no all-in-one-tool "change-ftype+assoc+openwith"
     

Share This Page

Loading...