4

Following some example code on the net, I got my first WiX installer to work. However, it placed my program menu shortcut directly on Program Menus. I really want to create a folder, Sample, in Program Menus for my link.

Original Code:

<Shortcut Id="startmenuSample" Directory="ProgramMenuFolder" Name="Sample 0.5"
WorkingDirectory='INSTALLDIR' Icon="Sample.exe" IconIndex="0" Advertise="yes">

Attempt at modifying code (fails with compiler error):

<Shortcut Id="startmenuSample" Directory="ProgramMenuFolder\Sample" Name="Sample 0.5"
WorkingDirectory='INSTALLDIR' Icon="Sample.exe" IconIndex="0" Advertise="yes">

Note the addition of \Sample.

How do I go about adding that link to a new folder in the Program Menu?

Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • Take a look at this http://www.tramontana.co.hu/wix/lesson1.php#1.2 – Shay Erlichmen Aug 12 '09 at 20:01
  • @Shay: Seen that one, but the problem I'm having is that he shows fragments of the XML file. It's not clear to me how the pieces nest / in what order they might have to be. – Eric J. Aug 12 '09 at 20:12
  • @Shay: Having just said that, I noticed that the download link for the complete sample a little further down in the tutorial. Will give that a try. – Eric J. Aug 12 '09 at 20:12

2 Answers2

5

This is a sample test I did, when I was asked to do the same thing

<Package InstallerVersion="200" Compressed="yes" />

<WixVariable Id="Manufacturer" Value="StackOverFlowHelper"/>
<WixVariable Id="ShortProduct" Value="ShortCuts"/>

<Media Id="1" Cabinet="WixShortCut.cab" EmbedCab="yes" />

<Icon Id="ShortCutIcon" SourceFile="YOUR.ico"/>

<!-- The icon that appears in Add & Remove Programs. -->
<Property Id="ARPPRODUCTICON" Value="ShortCutIcon" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">

    <Directory Id="ManufacturerFolder" Name="!(wix.Manufacturer)">
      <Directory Id="INSTALLLOCATION" Name="!(wix.ShortProduct)">
        <Component Id="ProductComponent" Guid="{YOUR_GUID}" KeyPath="yes">
          <CreateFolder/>
        </Component>
      </Directory>
    </Directory>
    <Directory Id="ProgramMenuFolder">
      <Directory Id="ProgramMenuManufacturer" Name="!(wix.ShortProduct)" />
    </Directory>
  </Directory>
</Directory>



<DirectoryRef Id="ProgramFilesFolder">
  <Component Id="ProgramMenuShortcuts" Guid="{YOUR_GUID}">
    <CreateFolder Directory="ProgramMenuManufacturer"/>
    <RemoveFolder Id="RemoveMenuShortcuts" Directory="ProgramMenuManufacturer" On="uninstall" />

    <RegistryValue Root="HKCU" Key="Software\!(wix.Manufacturer)\!(wix.ShortProduct)" Name="InstalledStartMenuShortcuts" Type="integer" Value="1" />
  </Component>
</DirectoryRef>

<DirectoryRef Id="INSTALLLOCATION" FileSource="Files">
  <Component Id="WixShortCut" Guid="{YOUR_GUID}">
    <File Id="Test.ShortCut" Vital="yes" Name="A_DOC.pdf" />

    <CreateFolder />
    <RegistryKey Root="HKCU" Key="Software\!(wix.Manufacturer)\!(wix.ShortProduct)" Action="createAndRemoveOnUninstall">
      <RegistryValue Name="ShortCut" Value="1" Type="integer" KeyPath="yes"/>
    </RegistryKey>

    <!-- Shortcut in Start menu. -->
    <Shortcut Id="ProgramMenuApplicationShortcut" Name="!(wix.ShortProduct)" Target="[#Test.ShortCut]"
                        Directory="ProgramMenuManufacturer" Show="normal" Icon="ShortCutIcon"/>
  </Component>
</DirectoryRef>

<Feature Id="ProductFeature" Title="WixShortCuts" Level="1">
  <ComponentRef Id="ProductComponent"/>
  <ComponentRef Id="ProgramMenuShortcuts"/>
  <ComponentRef Id="WixShortCut"/>
</Feature>

CheGueVerra
  • 7,849
  • 4
  • 37
  • 49
  • 1
    Thank you both for your suggestions. I'm sure both are correct, but this one provided me the key insight I needed. For others learning WiX, you may find this link useful: http://blogs.technet.com/alexshev/pages/from-msi-to-wix.aspx – Eric J. Aug 23 '09 at 23:21
2

In Windows Installer you need to create a new directory under ProgramMenuFolder and then reference it.

<Directory Id="ProgramMenuFolder" >
  <Directory Id="ProgramMenuDir" Name='My Folder'>
  </Directory>
</Directory>

<Shortcut Id="startmenuSample" Directory="ProgramMenuFolder" Name="Sample 0.5"
  WorkingDirectory='INSTALLDIR' Icon="Sample.exe" IconIndex="0" Advertise="yes">
Shay Erlichmen
  • 31,691
  • 7
  • 68
  • 87
  • My first attempt at trying this failed, though it could certainly be user error. Can you point to a complete example? – Eric J. Aug 12 '09 at 17:05