使用Wix创建/删除startmenu快捷方式的问题

时间:2011-09-09 16:55:29

标签: wix wix3.5

我正在尝试在我的应用程序的程序文件菜单上创建一个快捷方式。但是,由于我的公司可能有许多带有自己安装程序的产品,我希望将它们放在菜单上的子文件夹中,每个安装程序都会将其产品快捷方式添加到此子菜单。

到目前为止,我已经实现了这一点,但是当我卸载它时,它会在启动菜单上留下它的人工制品,如果我卸载所有它们仍然留下公司文件夹以及任何失败的子菜单。

这是我试图使用的WIX代码的一部分。我在不同产品的多个安装程序中使用相同的代码:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder" Name ="PFiles">
    <Directory Id="CompanyFolder" Name="!(loc.ManufacturerName)">
      <Directory Id="INSTALLDIR" Name="!(loc.ProductName)"/>
    </Directory>
  </Directory>
  <Directory Id="ProgramMenuFolder">
    <Directory Id="CompanyProgramsFolder" Name="!(loc.ManufacturerName)">
      <Directory Id="ProductFolder" Name="!(loc.ProductName)"/>
    </Directory>
  </Directory>
</Directory>

<DirectoryRef Id="CompanyProgramsFolder">
  <Component Id="CompanyProgramsFolderComponent" Guid="{SOME GUID}" >
    <RegistryValue Root="HKCU" Key="Software\!(loc.ManufacturerName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
  <RemoveFolder Id="CompanyProgramsFolder" On="uninstall"/>
  </Component>
</DirectoryRef>

  <DirectoryRef Id="ProductFolder">
  <Component Id="ApplicationShortcut" Guid="SOME GUID">
    <Shortcut Id="ApplicationStartMenuShortcut" Icon="Company.ico" Name="!(loc.ProductName)" Description="!(loc.ApplicationDescription)" Target="[INSTALLDIR]MyApplication.exe" WorkingDirectory="INSTALLDIR"/>
    <Shortcut Id="UninstallProduct" Icon="Company.ico" Name="Uninstall !(loc.ProductName)" Description="Uninstalls !(loc.ProductName)"
      Target="[SystemFolder]msiexec.exe"
      Arguments="/x [ProductCode]"/>
    <RemoveFolder Id="ProductFolder" On="uninstall"/>
    <RegistryValue Root="HKCU" Key="Software\!(loc.ManufacturerName)\!(loc.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
  </Component>
</DirectoryRef>

<!-- Set the components defined in our fragment files that will be used for our feature  -->
<Feature Id="MainFeature" Title="!(loc.ProductName)" Description="!(loc.ApplicationDescription)" Level="1">
  <ComponentGroupRef Id="Files" />
  <ComponentRef Id="CompanyProgramsFolderComponent" />
  <ComponentRef Id="ApplicationShortcut" />
</Feature>

有没有办法让它发挥作用?我不喜欢这些注册表值在这里播放的功能,所以我可能对使用它们感到天真。

1 个答案:

答案 0 :(得分:1)

尝试以下..这对我有用。                                                                                                                                                                          

 <DirectoryRef Id="ApplicationProgramsFolder">
  <Component Id="ApplicationShortcut" Guid="20BC8446-684B-44F5-A1E3-AF6010EAF37C">
    <Shortcut Id="ApplicationStartMenuShortcut"
        Name="Product Name Installer"
        Description="Product Name Installer"
        Target="[APPLICATIONROOTDIRECTORY]YourExe.exe"
        WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
            <Shortcut Id="UninstallProduct" 
                    Name="Uninstall Product Name"             
                  Target="[INSTALLLOCATION]YourExe.exe"
              Arguments="/x [ProductCode]" Description="Uninstalls Product Name" />
    <RemoveFolder Id="ApplicationProgramsFolder"
     On="uninstall"/>
    <RegistryValue Root="HKCU"
   Key="Software\Solution\Product name"

  Name="installed" Type="integer" Value="1" KeyPath="yes"/>
  </Component>
</DirectoryRef>

最后,在产品功能下添加此组件,如下所示(确保ID与上述匹配):

<ComponentRef Id="ApplicationShortcut" />