11

There are two answers on Create shortcut to desktop using WiX

Both these answers lack any real explanation of what is going on. What is the difference between these two methods of creating shortcuts? The first method falls in line with WiX - Create shortcut documentation.

The second method has a MergeRedirectFolder which I can't seem to find any documentation on, and I don't understand why the second example doesn't require the registry setting since according to WiX Documentation, a registry setting:

is required as a Shortcut cannot serve as the KeyPath for a component when installing non-advertised shortcuts for the current users.

Does this mean that the second method is an advertised shortcut? Or is it an answer that assumes the user is installing per machine? Or am I lost in the sauce? (Quite possible - second day trying to use WiX, since Microsoft forced me down this path.)

The first one:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="DesktopFolder" Name="Desktop">
    <Component Id="ApplicationShortcutDesktop" Guid="*">
      <Shortcut Id="ApplicationDesktopShortcut"
         Name="Text under your icon"
         Description="Comment field in your shortcut"
         Target="[MYAPPDIRPROPERTY]MyApp.exe"
         WorkingDirectory="MYAPPDIRPROPERTY"/>
      <RemoveFolder Id="DesktopFolder" On="uninstall"/>
      <RegistryValue
        Root="HKCU"
        Key="Software/MyAppName"
        Name="installed"
        Type="integer"
        Value="1"
        KeyPath="yes"/>
    </Component>
  </Directory>
    <Directory Id="ProgramFilesFolder" Name="PFiles">
      <Directory Id="MyCompany" Name="MyCompany">
        <Directory Id="MYAPPDIRPROPERTY" Name="MyAppName">
      </Directory>
    </Directory>
  </Directory>

The second one:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="DesktopFolder" SourceName="Desktop" />
  <Directory Id="MergeRedirectFolder">
    <Component Id="MyExeComponent" Guid="*">
      <File Id="MyExeFile" Source="$(var.ExeSourcePath)" KeyPath="yes">
        <Shortcut
          Id="DesktopShortcut"
          Directory="DesktopFolder"
          Name="$(var.ShortcutName)"
          WorkingDirectory="MergeRedirectFolder" />
      </File>
    </Component>
  </Directory>
</Directory>
Community
  • 1
  • 1
teynon
  • 7,540
  • 10
  • 63
  • 106
  • The documentation for WiX suggests the first method. http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/create_start_menu_shortcut.html I don't know if that discounts the second or not. – Peter Ritchie Jan 03 '14 at 18:11
  • @PeterRitchie That's the link I posted in the question. But yes, I agree the documentation suggests the first method. And arrived to the same point as your second statement. – teynon Jan 03 '14 at 18:23
  • I'd trust the documentation over what I'd read on stackoverflow. – Peter Ritchie Jan 03 '14 at 19:40
  • I actually just finished setting it up via the documentation, but I'd still like to know what's going on in the second one. Might help future SO's as well. – teynon Jan 03 '14 at 20:00
  • I wrote this a while back on the subject, but I am not sure how well it reads. Perhaps you can have a quick skim: **http://stackoverflow.com/questions/29255922/how-can-i-create-a-shortcut-on-the-users-desktop-folder/29498210#29498210** – Stein Åsmul May 04 '15 at 15:50

1 Answers1

5

Caveat: Per Doc's comment, since neither example specified the Advertise attribute, neither should create an advertised shortcut. I don't remember what led me to write the answer below; it seems likely to be incorrect. I'll leave the answer in tact in case there is some subtle truth behind it.


The first example creates an advertised shortcut; the second creates a non-advertised shortcut. The rules for the two types of shortcuts are described with the Shortcut Table Target column.

A non-advertised shortcut is a standard Windows shortcut like you would create with Windows Explorer. An advertised shortcut enhances resiliency by verifying that all the components in the feature are installed when the shortcut is activated.

Edward Brey
  • 40,302
  • 20
  • 199
  • 253
  • The first example is not an advertised shortcut since that would need the `Advertise` attribute. Other than that, I haven't delved too deeply into the differences and went on ahead and used the first example. – Doc May 04 '15 at 11:36
  • 1
    An advertised shortcut points to an MSI feature and triggering it will lead to all key paths in that feature and all its parent features to be validated. If a problem is found for any key path, a self-repair is triggered for the affected features and the missing components are (re)installed. This validation check is sometimes used to add per-user data for each Windows user when they launch their application (userdata or HKCU data). – Stein Åsmul May 04 '15 at 15:54