Reputation: 33
I have an Internet Explorer Add-On that generates some files in LocalAppDataFolder\Microsoft\Windows\Temporary Internet Files\CompanyName\AddOnName\
I have a WIX installer for the application that I would like to have delete the CompanyName\AddOnName\ folders on both install and uninstall.
I have never used WIX before, and I'm more of a MacOS guy, so all of this stuff is a bit foreign to me. Here is a portion of what I have right now (in my Product.wxs file):
<Feature Id="ProductFeature" Title="Company IE Add-On" Level="1" ConfigurableDirectory="INSTALLFOLDER">
<ComponentRef Id="INSTALLFOLDER" />
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="dataDirectory"/>
</Feature>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Company IE Add-On" >
<Component Id="INSTALLFOLDER" Guid="THERE IS A GUID HERE">
<RemoveFolder On="both" Id="INSTALLFOLDER"/>
<RegistryValue Root="HKLM" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="Company IE Add-On" />
</Component>
</Directory>
</Directory>
<Directory Id="LocalAppDataFolder">
<Directory Id="Microsoft">
<Directory Id="Windows">
<Directory Id="TempInetFiles" Name="Temporary Internet Files">
<Directory Id="CompanyName">
<Directory Id="AddOnName">
<Component Id="dataDirectory" Guid="E5938D44-5315-43D4-94EC-313F6CDB290B" NeverOverwrite="no" Permanent="no">
<RemoveFolder Id="AddOnName" On="both"/>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
But this is giving me errors like "Component dataDirectory installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file."
And "The directory CompanyName is in the user profile but is not listed in the RemoveFile table."
Any help would be greatly appreciated. Thanks.
Upvotes: 1
Views: 3318
Reputation: 508
WiX requires that you always use an HKCU registry entry whenever creating a user-specific component. In this case, dataDirectory will always be installed in the current user's profile. Add an HKCU or HKMU registry element inside the component as in:
<Component Id="dataDirectory" Guid="E5938D44-5315-43D4-94EC-313F6CDB290B" NeverOverwrite="no" Permanent="no">
<Registry Root='HKMU' Key='Software\[Manufacturer]\[ProductName]' KeyPath='yes'/>
<RemoveFolder Id="AddOnName" On="both"/>
</Component>
This will not have any visible effect in case of a per-machine installation as you already have HKLM\Software[Manufacturer][ProductName]. In case of a per-user installation, it will create HKCU\Software[Manufacturer][ProductName].
Replace the HKMU with HKCU if it still fails with the same error.
For the second problem, check out: Directory xx is in the user profile but is not listed in the RemoveFile table.
Upvotes: 0
Reputation: 3797
I do something similar and this code works for me:
<!--Setting up the shortcuts for the product-->
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="ProgramMenuDir" Name="$(var.ShortcutName)">
<Directory Id="ProgramMenuSubFolder" Name="LOGGERS">
</Directory>
</Directory>
</Directory>
</Directory>
<Component Id='LoggersShortcut' Guid='2A6D411E-5CE9-4F38-8F25-361CBFCABB5A' Directory='ProgramMenuSubFolder'>
<CreateFolder Directory="ProgramMenuSubFolder" />
<RemoveFolder Id='ProgramMenuSubFolder' On='uninstall' Directory='ProgramMenuSubFolder'/>
<RegistryValue Root='HKCU' Key='Software\ShortcutProperty\[PRODUCTNAME]' Type='string' Value='1' KeyPath='yes' />
</Component>
Upvotes: 0