Domanda

Come posso creare sottocartelle (con diversi livelli di profondità) nel menu Start di Windows, usando WiX?

Attualmente sono in grado di mettere il mio collegamento nel menu Start, ma solo in una cartella immediatamente in Programmi (Start / Programmi / MyFolder), ma voglio annidare il mio collegamento più in profondità (Start / Programmi / MyPlatform / MyProduct / etc .). Ho provato combinazioni diverse, ma purtroppo.

<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>
È stato utile?

Soluzione

Ciò che rende le cose interessanti è che MSI richiede la creazione di un valore di registro come modo per rilevare se il componente è stato installato. Se preferiamo creare un solo valore del registro per tutte le scorciatoie, dovremo mettere tutte le scorciatoie in un singolo componente.

Fortunatamente è possibile creare componenti che si estendono su più directory di destinazione usando l'attributo Directory su Elemento di scelta rapida .

   <!-- 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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top