0

I have the following (default) markup for my WiX installer project:

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='ProgramFilesFolder' Name='PFiles'>
    <Directory Id='Acme' Name='Acme'>
      <Directory Id='INSTALLDIR' Name='Foobar 1.0'>

        <Component Id='MainExecutable' Guid='*'>
          <File Id='FoobarEXE' Name='FoobarAppl10.exe' DiskId='1'
                Source='FoobarAppl10.exe' KeyPath='yes'>
            <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" 
                      Name="Foobar 1.0" WorkingDirectory='INSTALLDIR' 
                      Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
            <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" 
                      Name="Foobar 1.0" WorkingDirectory='INSTALLDIR'
                      Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
          </File>
        </Component>

        <Component Id='HelperLibrary' Guid='*'>
          <File Id='HelperDLL' Name='Helper.dll' DiskId='1' 
                Source='Helper.dll' KeyPath='yes' />
        </Component>

        <Component Id='Manual' Guid='*'>
          <File Id='Manual' Name='Manual.pdf' DiskId='1' 
                Source='Manual.pdf' KeyPath='yes'>
            <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" 
                      Name="Instruction Manual" Advertise="yes" />
          </File>
        </Component>

      </Directory>
    </Directory>
  </Directory>

  <Directory Id="ProgramMenuFolder" Name="Programs">
    <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
      <Component Id="ProgramMenuDir" Guid="*">
        <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' 
                       Type='string' Value='' KeyPath='yes' />
      </Component>
    </Directory>
  </Directory>

  <Directory Id="DesktopFolder" Name="Desktop" />
</Directory>

It compiles into the following MSI:

enter image description here

I'm wondering, can I add "Create desktop shortcuts" option to that installation tree so that users could select or remove it?

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
c00000fd
  • 20,994
  • 29
  • 177
  • 400

1 Answers1

3

You just need to move the Shortcut elements into their own component(s), and add those to a new Feature.

This guide does it that way: How To: Create a Shortcut on the Start Menu

Dave Andersen
  • 5,337
  • 3
  • 30
  • 29
  • I tried it, but then I need conditional creation of those shortcuts. For instance, if a user selects "Create desktop shortcuts" option and unchecks "Description", this should create only "Program" shortcuts, and I can't figure out how to add this condition. – c00000fd Apr 04 '14 at 22:15
  • I think what you want to do is a bit tricky in MSI. I think it may be possible conditioning on the Feature states, but it's not going to be straight-forward. See this post: http://www.joyofsetup.com/2008/04/09/feature-states-in-component-conditions/ One way you could do it is by making a shortcut Feature as a child of each Feature which needs shortcuts. More clicking for users, but it's much simpler from the MSI perspective. – Dave Andersen Apr 04 '14 at 22:47