[wix-users] RemoveRegistryKey in a dual-scope MSI

Alan Sinclair anadem at gmail.com
Fri Apr 20 22:18:53 PDT 2018


Is there any way to do set up my dual-scope install so that at uninstall it
removes a registry key (from the appropriate HKLM or HKCU hive depending
whether it's in per-machine mode or per-user mode) ONLY AT FINAL UNINSTALL,
not at upgrade?
All the dual-scope stuff is working cleanly and properly now (including
upgrades!) thanks to all the great help from this list, except cleaning up
the registry keys which were set by the app i.e. not set by components in
the installer.

I have RemoveRegistryKey in a component conditioned on
NOT UPGRADINGPRODUCTCODE but that doesn't do what we need: the key is
removed during an upgrade.

This is what I've got:

        <DirectoryRef Id='TARGETDIR'>
            <Component Id="AlanRemoveRegHKLM" Guid="myguid"
Win64='$(var.V_WIN64)'>
                <Condition> ( not UPGRADINGPRODUCTCODE ) and ALLUSERS
</Condition>
                <RemoveRegistryKey Root="HKLM"
Key="Software\Myapp\Settings" Action="removeOnUninstall" />
            </Component>
            <Component Id="AlanRemoveRegHKCU" Guid="myguid2"
Win64='$(var.V_WIN64)'>
                <Condition> ( not UPGRADINGPRODUCTCODE ) and ( not ALLUSERS
)</Condition>
                <RemoveRegistryKey Root="HKMU" Key="Software\Myapp\Settings
" Action="removeOnUninstall" />
            </Component>
        </DirectoryRef>

which gets this warning:

c:\projects\ws\wixsetup\wsoptions.wxs(285) : warning LGHT1076 : ICE57:
Component 'AlanRemoveRegHKCU' has a registry entry that can be either
per-user or per-machine and a per-machine KeyPath.
C:\Users\AlanSinclair\AppData\Local\Temp\3crnd1nz\myapp-en-us.msi : warning
LGHT1076 : ICE105: msidbRegistryRootLocalMachine or msidbRegistryRootUsers
cannot be defined as root for per user install of application.

How to make this aware of UPGRADINGPRODUCTCODE ? Do we need a custom action
to save and restore the key over an upgrade?

(Also, I don't know if the condition REMOVE~="ALL" is required in the
condition when Action=" removeOnUninstall " .. is it?)

Any ideas?
Thanks
Alan


More information about the wix-users mailing list