加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

安装程序 – 如何使用WiX在开始菜单中创建多级子文件夹

发布时间:2020-12-13 20:13:50 所属栏目:Windows 来源:网络整理
导读:如何使用WiX在 Windows开始菜单中创建子文件夹(多个级别)? 目前,我可以把我的快捷方式放在开始菜单中,但只能在程序(开始/程序/ MyFolder)下的一个文件夹中,但是我想更深入地嵌入我的快捷方式(开始/程序/ MyPlatform / MyProduct /等等).我尝试了不同的组合,
如何使用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="SOFTWAREMyCompanyMyPlatformMy 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="SoftwareMyVendorMyProduct"
            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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读