I'm using Wix 3.9 and Wix-edit 0.7.5/Notepad++ to create a MSI installer for my application. I want to create an uninstall shortcut inside the installed folder. For instance:
C:\MySoftware\Uninstall.lnk
I tried a few things, but in all cases when I uninstall the software through that link, the program folder C:\MySoftware
is not deleted. Uninstalling every other way works as expected.
First I tried to create it as a Component inside the <Directory>
tag. Looks to me a bit hacky, because I must add <CreateFolder>
:
<Directory Id="MYINSTALLDIR" Name="MySoftware">
<!-- my files... -->
<Component Id="ABC" Guid="PUT-GUID-HERE">
<CreateFolder/> <!-- have to add this -->
<Shortcut Id="UninstallProduct" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]"/>
</Component>
</Directory>
<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
<!-- some references... -->
<ComponentRef Id="ABC" />
</Feature>
I also tried replacing <CreateFolder/>
with <RemoveFolder Id="MYINSTALLDIR" On="uninstall" />
, same results.
Another try:
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="StartMenuShortcuts" Guid="*">
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" />
<Shortcut Id="UninstallProduct1" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]"/>
<Shortcut Id="UninstallProduct2" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]" Directory="MYINSTALLDIR" />
</Component>
</DirectoryRef>
Here, besides having the same results, I get a warning when building: file.wxs(31) : warning LGHT1076 : ICE57: Component 'StartMenuShortcuts' has both per-user and per-machine data with an HKCU Registry KeyPath.
.
How do I create a shortcut that can be used without affecting the uninstall behavior? I don't know if it makes a difference, but I need this to work without Admin privileges (I'm using <Package ... InstallScope="perUser" InstallPrivileges="limited">
).
I know I could just create a .lnk file and add it to the project, but I prefer not to, because then I'd have to worry about updating its GUID on every project.