views:

2266

answers:

1

Hi guys. How do I create sub folders (several levels deep) in the Windows Start menu, using Wix? Currently I am able to put my shortcut in the Start menu, but only in a folder immediately under Programs (Start / Programs / MyFolder), but I want to nest my shortcut deeper (Start / Programs / MyPlatform / MyProduct / etc). I tried different combinations, but alas. Thank you!

<DirectoryRef Id="StartMenuMyProduct">
  <Component Id="ApplicationShortcut" Guid="{PUT-SOME-GUID-HERE}">
    <Shortcut Id="ApplicationStartMenuShortcut"
              Name="Configure My Product"
              Description="Add or remove this and that"
              Target="[MYPRODUCTDIR]ConfigureMyProduct.exe"
              WorkingDirectory="MYPRODUCTDIR"/>
    <RemoveFolder Id="StartMenuMyProduct" On="uninstall"/>
    <RemoveFolder Id="StartMenuMyPlatform" On="uninstall"/>
    <RegistryValue Root="HKCU" Key="SOFTWARE\MyCompany\MyPlatform\My Product"
                       Name="Installed" Type="integer" Value="1" KeyPath="yes"/>
  </Component>
</DirectoryRef>


<!-- Shortcut to the configuration utility in the Windows Start menu -->
<Directory Id="ProgramMenuFolder">
  <!--<Directory Id="StartMenuMyPlatform" Name="MyPlatform">-->
    <Directory Id="StartMenuMyProduct" Name="My Product" />
  <!--</Directory>-->
</Directory>
+10  A: 

What makes things interesting is that MSI demands a registry value to be created as a way to detect whether the component has been installed. If we prefer to create only one such registry value for all shortcuts, then we'll have to put all our shortcuts in a single component.

Fortunately it is possible to create components which span multiple target directories by making use of the Directory attribute on the Shortcut element.

   <!-- shortcuts to applications in the start menu -->
   <DirectoryRef Id="ProgramMenuProductFolder">
      <Component Id="ProgramMenuShortcutsComponent" Guid="PUT-GUID-HERE">
         <!-- create folders -->
         <CreateFolder Directory="ProgramMenuVendorFolder" />
         <CreateFolder Directory="ProgramMenuProductFolder" />
         <CreateFolder Directory="ProgramMenuSubFolder" />
         <!-- remove folder -->
         <RemoveFolder Id="RemoveProgramMenuVendorFolder"
            Directory="ProgramMenuVendorFolder"
            On="uninstall" />
         <RemoveFolder Id="RemoveProgramMenuProductFolder"
            Directory="ProgramMenuProductFolder"
            On="uninstall" />
         <RemoveFolder Id="RemoveProgramMenuProductSubFolder"
            Directory="ProgramMenuProductSubFolder"
            On="uninstall" />
         <!-- main shortcut -->
         <Shortcut
            Id="MainShortcut"
            Name="My Product"
            Target="[SomeInstalledFolder]app1.exe" />
         <!-- shortcut in subfolder -->
         <Shortcut
            Id="SubFolderShortcut"             
            Name="mySubFolderShortcut"
            Target="[SomeInstalledFolder]app2.exe"
            Directory="ProgramMenuProductSubFolder" />
         <!--
            RegistryValue whichs serves as KeyPath
         -->
         <RegistryValue
            Root="HKCU"
            Key="Software\MyVendor\MyProduct"
            Name="InstalledStartMenuShortcuts"
            Type="integer"
            Value="1" />
      </Component>
   </DirectoryRef>

   <!-- shortcut directories -->
   <Directory Id="ProgramMenuFolder">
      <Directory Id="ProgramMenuVendorFolder" Name="MyVendor">
         <Directory Id="ProgramMenuProductFolder" Name="MyProduct">
            <Directory Id="ProgramMenuProductSubFolder" Name="MySubFolder" />
         </Directory>
      </Directory>
   </Directory>
Wim Coenen
Thank you, it works! :)
Levon
Minor clarification, it's not WiX that requires the registry value, it's MSI. We're just living by the lame requirements.
Rob Mensching

related questions