0

Is there a way in WIX that allows me to specify that a certain application should be treated as the default one when the user double clicks on a file with a certain extension?

For example, let's say I have an application A, whose installer sets the following association:

  <ProgId Id="XYZFile" Description="App A file">
    <Extension Id="xyz" ContentType="application/text">
      <Verb Id="open" Command="Open" TargetFile="A.exe" Argument='"%1"' />
    </Extension>
  </ProgId>

And then I have application B that deals with the same extension and sets the following association:

  <ProgId Id="XYZFile" Description="App B file">
    <Extension Id="xyz" ContentType="application/text">
      <Verb Id="open" Command="Open" TargetFile="B.exe" Argument='"%1"' />
    </Extension>
  </ProgId>

Is there a way to make app B the default one for the file extension specified, in the following scenarios:

  • User installs app A, which associates the extension xyz with app A, then installs app B. In this case the desired behaviour is for app B to launch when the user double clicks on the file.
  • User installs app B, then installs app A. In this case the desired behaviour is for app B to launch when the user double clicks on the file. So installing app A does not overwrite the default file association.
  • User uninstalls app B, file association defaults back to app A.
  • User uninstalls app A, file association remains with app B.

I had several attempts at googling a similar requirement and solution, but so far haven't found a clear answer.

Kakalokia
  • 3,191
  • 3
  • 24
  • 42
  • This is largely an anti-pattern of the technology - the difficulty of handling advanced file association issues - each install things it "owns" the association. Could you instead use the application itself on first launch to write the keys to the HKCU registry hive instead? **`HKCU\Software\Classes`** - just asking before writing up anything on that. There is also the **`HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts`** location (sub keys) which stores what application the user used from the ***"Open With"*** dialog. Not sure what takes precedence in what version of Windows. – Stein Åsmul Feb 12 '20 at 01:26
  • [Reference material - learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/shell/fa-intro). – Stein Åsmul Feb 12 '20 at 11:10
  • A similar (and very old) question: https://stackoverflow.com/questions/138550/how-to-register-file-types-extensions-with-a-wix-installer – KargWare Feb 20 '20 at 13:23

0 Answers0