0

In my Wix project, I need to set an external application as the default program for a new file type, so I add some file associations in registry keys(weird I know, but I'm developing a plugin and I don't find a native way to deal with external programs). MSDN says we should call SHChangeNotify if we change file associations. If not, the new association will not work until the system restarts. Here is my problem, how can I do this in Wix? I find a tool which implements this feature but what I need is hard code this in Wix Installer.

[solution] At first I add ProgId element the way @BdN3504 shows. Then I use Custom Action to send SHChangeNotify. Cheers~

Community
  • 1
  • 1
Rebornix
  • 5,272
  • 1
  • 23
  • 26

1 Answers1

1

Have you had a look at this answer?

You have to first locate the target application in a FileSearch and then reference that in an Extension element.

<Property Id="TARGETEXE">
    <DirectorySearch Path="C:\Program Files (x86)\App"
        Depth="0"
        AssignToProperty="no"
        Id="NppSearch">
            <FileSearch Name="Target.exe"
                Id="targetExeFileSearch" />
    </DirectorySearch>
</Property>
<ProgId Id='Fileassoc.assoc' Description='File extension description'>
  <Extension Id='assoc' ContentType='application/assoc'>
    <Verb Id='open' Command='Open' TargetProperty='TARGETEXE' Argument='"%1"' />
  </Extension>
</ProgId>

See the documentation for the

Community
  • 1
  • 1
BdN3504
  • 1,693
  • 21
  • 29
  • Many Thanks! It works for External Programs. But seems that it still doesn't send SHChangeNotify. For example, I set GVim as the default program of XML. After installing the plugin, the icons of XML files won't change, but if I double click XML files, they will be opened by GVim correctly. The icons will change to the new one(GVim icon) only after rebooting or sending SHChangeNotify manually. Any idea about this? – Rebornix Sep 20 '13 at 16:37
  • Sorry, no I don't have any idea about this. Maybe this could be formulated as a feature request or a bug report. The wix bugtracker is here: http://wixtoolset.org/issues/ Another option would be that you pose this question on the mailing list here: http://wixtoolset.org/documentation/mailinglist/ There could also be a wrapper around this function in the Deployment Tools Foundation. The last option would be to hope that one of the developers comments on this issue here on stackoverflow. – BdN3504 Sep 20 '13 at 17:17