installation - 如何使用 WiX 在开始菜单中创建多级子文件夹

标签 installation wix windows-installer wix3

如何使用 WiX 在 Windows“开始”菜单中创建子文件夹(几级深)?

目前,我可以将快捷方式放在“开始”菜单中,但只能放在“程序”正下方的文件夹中(“开始”/“程序”/“MyFolder”),但我想将快捷方式嵌套得更深(“开始”/“程序”/MyPlatform/MyProduct/等) .)。我尝试了不同的组合,但可惜。

<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>

最佳答案

有趣的是 MSI 要求创建一个注册表值来检测组件是否已安装。如果我们希望为所有快捷方式只创建一个这样的注册表值,那么我们必须将所有快捷方式放在一个组件中。

幸运的是,可以通过使用 Shortcut element 上的 Directory 属性来创建跨多个目标目录的组件。 。

   <!-- 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>

关于installation - 如何使用 WiX 在开始菜单中创建多级子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/470662/

相关文章:

ubuntu - 在docker下安装时可以回答对话问题吗?

installation - 如何在WiX中至少需要两个可选组件之一?

visual-studio-2010 - InstallShield Limited Edition - 一般信息页面和 VS 2010 崩溃的问题

visual-studio-2010 - 如何将 100 多个 Visual Studio 安装程序项目 (vdproj) 转换为 Wix 安装程序?

visual-studio-2010 - WiX 'Bundle' 'ExePackage' 'DetectCondition' 总是假的

c++ - 通过 msi.dll 一次更改 MSI 表中列中的所有值

makefile - 如何指定./configure的参数 '--includedir'和 '--libdir'给cmake

python - 似乎无法在 Windows 上为 python 2.7 安装 pandas

wix - 如何避免通过WiX/MSI软件包触发MSI自修复?

c# - .NET 4.0 自定义操作失败