WiX 3程序菜单文件夹中的文件夹

时间:2009-08-09 18:20:34

标签: wix wix3

按照网上的一些示例代码,我得到了第一个WiX安装程序。但是,它将我的程序菜单快捷方式直接放在程序菜单上。我真的想在Program Menus中为我的链接创建一个文件夹Sample。

原始代码:

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

尝试修改代码(编译错误失败):

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

请注意添加 \ Sample

如何将该链接添加到程序菜单中的新文件夹?

2 个答案:

答案 0 :(得分:5)

这是我做过的样本测试,当时我被要求做同样的事情

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

答案 1 :(得分:2)

在Windows Installer中,您需要在ProgramMenuFolder下创建一个 new 目录,然后引用它。

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