Search code examples
wpfwixsetup-project

Adding App to "Choose A Default Browser" via Wix Setup Project


I have an application that I'm trying to get to show up in "Choose A Default Browser" after installation on Windows 8.1 and 10. I followed another link, and was able to setup the following registry keys via the Wix Setup Project. All the keys are created on install, however, the application doesn't show up in the web browser list. Anyone know what I'm missing?

<Fragment>
<DirectoryRef Id="TARGETDIR">
  <Component Id="RegistryEntries" Guid="8b810d67-345d-4652-bf17-a503d120cccc">
    <RegistryKey Root="HKLM"
                 Key="Software\MyApp"
                 Action="createAndRemoveOnUninstall">
      <RegistryKey Key="Capabilities"
                   Action="createAndRemoveOnUninstall">
        <RegistryValue Type="string" Name="ApplicationName" Value="MyApp"/>
        <RegistryValue Type="string" Name="ApplicationIcon" Value="C:\Program Files (x86)\MyApp\MyApp.exe,0"/>
        <RegistryValue Type="string" Name="ApplicationDescription" Value="A safe browsing experience."/>
          <RegistryKey Key="FileAssociations"
                       Action="createAndRemoveOnUninstall">
            <RegistryValue Type="string" Name=".htm" Value="MyApp"/>
            <RegistryValue Type="string" Name=".html" Value="MyApp"/>
            <RegistryValue Type="string" Name=".shtml" Value="MyApp"/>
            <RegistryValue Type="string" Name=".xht" Value="MyApp"/>
            <RegistryValue Type="string" Name=".xhtml" Value="MyApp"/>
          </RegistryKey>
          <RegistryKey Key="URLAssociations"
                     Action="createAndRemoveOnUninstall">
              <RegistryValue Type="string" Name="http" Value="MyApp"/>
              <RegistryValue Type="string" Name="https" Value="MyApp"/>
              <RegistryValue Type="string" Name="ftp" Value="MyApp"/>
          </RegistryKey>
      </RegistryKey>
    </RegistryKey>
    <RegistryKey Root="HKLM"
                 Key="SOFTWARE\RegisteredApplications"
                 Action="none">
      <RegistryValue Type="string" Name="MyApp" Value="Software\MyApp\Capabilities"/>
    </RegistryKey>
    <RegistryKey Root="HKLM"
                 Key="Software\Classes\MyApp"
                 Action="createAndRemoveOnUninstall">
      <RegistryValue Type="string" Value="MyApp Document"/>
      <RegistryKey Key="shell"
                   Action="createAndRemoveOnUninstall">
        <RegistryKey Key="open"
                             Action="createAndRemoveOnUninstall">
          <RegistryKey Key="command"
                               Action="createAndRemoveOnUninstall">
            <RegistryValue Type="string" Name="MyApp" Value="&quot;C:\Program Files (x86)\MyApp\MyApp.exe&quot; &quot;%1&quot;"/>
          </RegistryKey>
        </RegistryKey>
      </RegistryKey>
    </RegistryKey>
  </Component>
</DirectoryRef>

If you spot a missing element, please let me know.


Solution

  • I figured it out, so I thought I'd go ahead and post the answer for ya'll. When creating the "command" key inside of "Software\Classes\MyApp\shell\open", I had to remove the "Name" of the registry value, so that my registry value would be written to the "(Default)" string.

    <RegistryKey Key="command"
                 Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Value="&quot;C:\Program Files 
                   (x86)\MyApp\MyApp.exe&quot; &quot;%1&quot;"/>
    

    So my final working code in the Product.wxs file to get all the keys created, and my application in the "Choose a Web Browser" section was:

    <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Component Id="RegistryEntries" Guid="8b810d67-345d-4652-bf17-a503d120cccc">
        <RegistryKey Root="HKLM"
                     Key="Software\MyApp"
                     Action="createAndRemoveOnUninstall">
          <RegistryKey Key="Capabilities"
                       Action="createAndRemoveOnUninstall">
            <RegistryValue Type="string" Name="ApplicationName" Value="MyApp"/>
            <RegistryValue Type="string" Name="ApplicationIcon" Value="C:\Program Files (x86)\MyApp\MyApp.exe,0"/>
            <RegistryValue Type="string" Name="ApplicationDescription" Value="A safe browsing experience."/>
              <RegistryKey Key="FileAssociations"
                           Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Name=".htm" Value="MyApp"/>
                <RegistryValue Type="string" Name=".html" Value="MyApp"/>
                <RegistryValue Type="string" Name=".shtml" Value="MyApp"/>
                <RegistryValue Type="string" Name=".xht" Value="MyApp"/>
                <RegistryValue Type="string" Name=".xhtml" Value="MyApp"/>
              </RegistryKey>
              <RegistryKey Key="URLAssociations"
                         Action="createAndRemoveOnUninstall">
                  <RegistryValue Type="string" Name="http" Value="MyApp"/>
                  <RegistryValue Type="string" Name="https" Value="MyApp"/>
                  <RegistryValue Type="string" Name="ftp" Value="MyApp"/>
              </RegistryKey>
          </RegistryKey>
        </RegistryKey>
        <RegistryKey Root="HKLM"
                     Key="SOFTWARE\RegisteredApplications"
                     Action="none">
          <RegistryValue Type="string" Name="MyApp" Value="Software\MyApp\Capabilities"/>
        </RegistryKey>
        <RegistryKey Root="HKLM"
                     Key="Software\Classes\MyApp"
                     Action="createAndRemoveOnUninstall">
          <RegistryValue Type="string" Value="MyApp Document"/>
          <RegistryKey Key="shell"
                       Action="createAndRemoveOnUninstall">
            <RegistryKey Key="open"
                                 Action="createAndRemoveOnUninstall">
              <RegistryKey Key="command"
                                   Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Value="&quot;C:\Program Files (x86)\MyApp\MyApp.exe&quot; &quot;%1&quot;"/>
              </RegistryKey>
            </RegistryKey>
          </RegistryKey>
        </RegistryKey>
      </Component>
    </DirectoryRef>