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>
5
  • The documentation for WiX suggests the first method. wixtoolset.org/documentation/manual/v3/howtos/… I don't know if that discounts the second or not. Jan 3, 2014 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 3, 2014 at 18:23
  • I'd trust the documentation over what I'd read on stackoverflow. Jan 3, 2014 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 3, 2014 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: stackoverflow.com/questions/29255922/… May 4, 2015 at 15:50

1 Answer 1

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.

2
  • 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 4, 2015 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). May 4, 2015 at 15:54

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.