1

In my WiX installer, if I use this code, my desktop shortcut works perfectly fine:

<Component Id="TrayWithStartMenuAndDesktopShortcuts" Directory="INSTALLFOLDER" Permanent="no" SharedDllRefCount="no" Transitive="no">
  <Condition><![CDATA[STARTMENUSHORTCUT="1" AND DESKTOPSHORTCUT="1"]]></Condition>
  <File Id="TrayFileWithStartMenuAndDesktopShortcuts" DiskId="1" Hidden="no" ReadOnly="no" System="no" Vital="yes" Compressed="yes" Name="Tray.exe" Source="Tray.exe" KeyPath="yes">
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsDesktopShortcut" Directory="DesktopFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsProgramFilesShortcut" Directory="ProgramMenuFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
  </File>
</Component>

But when I use the following code, any time I double click my desktop shortcut, an error message pops up saying, "Component not used on this computer.":

<Component Id="TrayWithStartMenuAndDesktopShortcuts" Directory="INSTALLFOLDER" Permanent="no" SharedDllRefCount="no" Transitive="no">
  <Condition><![CDATA[STARTMENUSHORTCUT="1" AND DESKTOPSHORTCUT="1"]]></Condition>
  <File Id="TrayFileWithStartMenuAndDesktopShortcuts" DiskId="1" Hidden="no" ReadOnly="no" System="no" Vital="yes" Compressed="yes" Name="Tray.exe" Source="Tray.exe" KeyPath="yes">
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsDesktopShortcut" Directory="DesktopFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsProgramFilesShortcut" Directory="ProgramMenuFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
  </File>
</Component>
<Component Id="TrayWithStartMenuShortcut" Directory="INSTALLFOLDER" Permanent="no" SharedDllRefCount="no" Transitive="no">
  <Condition><![CDATA[STARTMENUSHORTCUT="1" AND DESKTOPSHORTCUT<>"1"]]></Condition>
  <File Id="TrayFileWithStartMenuShortcut" DiskId="1" Hidden="no" ReadOnly="no" System="no" Vital="yes" Compressed="yes" Name="Tray.exe" Source="Tray.exe" KeyPath="yes">
    <Shortcut Id="TrayFileWithStartMenuShortcutProgramFilesShortcut" Directory="ProgramMenuFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
  </File>
</Component>

Note how the installation changes based on the conditions that are met. What can I do to install my shortcuts conditionally like this and make them work properly?

Alexandru
  • 12,264
  • 17
  • 113
  • 208

1 Answers1

1

Looks like its because the shortcuts are advertised, and apparently advertised shortcuts won't run unless all components under a feature are installed, which in my case, not all were since some were conditional. I went with refactoring this to use Raymond's answer at: Create shortcut to desktop using WiX

Community
  • 1
  • 1
Alexandru
  • 12,264
  • 17
  • 113
  • 208