Issue creating/removing startmenu shortcuts with Wix
I'm trying to create a shortcut on the program files menu for my application. However, as my company may have a number of products with their own installers I want to have them in sub folders on the menu where each installer add its products shortcuts to this submenu.
So far I have achieved this but when I uninstall one it leaves its artefacts behind on the startup menu, and if I uninstall all of them it still leaves behind the Compan开发者_StackOverflow中文版y Folder as well as any failed sub menus.
Heres a section of the WIX code which I was attempting to use. I'm using the same code in multiple installers for the different products:
<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>
Is there a way to get this to work? I'm not to comfortable with what functionality the Registry values are playing here so I may have been naive with my use of them.
Try the following..it works for me.
<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>
Finally, add this component under your product feature as follows (make sure the ID matches above):
<ComponentRef Id="ApplicationShortcut" />
精彩评论