3

I have the following situation.

My product installs the binaries inside c:\Program Files (x86)\MyCompany\MyApp\ and a shortcut under C:\ProgramData\Microsoft\Windows\Start Menu\Programs\MyCompany.

I build the msi using this great example: https://helgeklein.com/blog/2014/09/real-world-example-wix-msi-application-installer/

I just added the following piece of code

  <!-- ApplicationShortcut-->
  <Directory Id="ProgramMenuFolder">

    <Directory Id="ApplicationProgramsFolder" Name="!(loc.ManufacturerName)">

      <Component Id="ApplicationShortcut" Guid="F4B7EAFA-FF19-41B4-8267-3AEFC12235A7">
        <Shortcut Id="ApplicationStartMenuShortcut"
             Name="!(loc.ApplicationName)"
             Description="!(loc.ProductDescription)"
             Target="[INSTALLDIR]MyApp.exe"
             WorkingDirectory="INSTALLDIR"
    />
        <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\!(loc.ManufacturerName)\!(loc.ApplicationName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>

    </Directory>

  </Directory>

The problem is the following

  • I install the application the fist time, it will install the shortcut just fine
  • Now I start the app and choose Pin to taskbar, this will create a shortcut inC:\Users\\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar`
  • If I rebuild the msi and execute the setup again, the taskbar shortcut is not clickable anymore, because the shortcut in C:\Users\<user>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar is missing

Is it possible to maintain the taskbar shortcut during an update?

Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
  • 1
    Would this happen if the MSI that is installed is a minor upgrade instead of a major upgrade? What about advertised versus non-advertised shortcuts? I have never tried, maybe you know off the top of your head. – Stein Åsmul Dec 07 '18 at 14:09

1 Answers1

1

I found the answer here: https://stackoverflow.com/a/33402698/98491

<InstallExecuteSequence>
  <RemoveShortcuts>Installed AND NOT UPGRADINGPRODUCTCODE</RemoveShortcuts>
</InstallExecuteSequence>

This prevents shortcuts from being uninstalled during an update.

As described in the comments, the disadvantage is that, after uninstall, the TaskBarShortCut remains, but that is something that a user might expect. Having to recreate a pinned taskbar shortcut everytime he updates a software is not.

Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
  • I would test this properly. If that shortcut is advertised it points to a product feature, and not a file. It might work, or it might not. Test a full major upgrade with and without pinning? – Stein Åsmul Dec 12 '18 at 02:33
  • Might be, but I don't have advertised shortcuts. I tried an upgrade from 1.8 to 1.9 and it worked. I will try an update to 2.x and an uninstall, and update the answer, if this will fail – Jürgen Steinblock Dec 12 '18 at 11:03
  • OK, just trying to give you a heads-up. Windows is a "moving target" for all of us. Behavior we depend upon suddenly changes at times. A non-advertised shortcut does point to a file though (generally, unless made not to). – Stein Åsmul Dec 12 '18 at 11:05
  • `A non-advertised shortcut does point to a file though` What do you mean? As a target or KeyPath? I use heat to harvest my files into a component, so I can't place a shortcut tag inside a file tag but using `Target="[INSTALLDIR]MyApp.exe"` works fine. – Jürgen Steinblock Dec 12 '18 at 13:19