Wix - how to run an exe after installfinalize upon uninstall?
Asked Answered
S

1

5

I am using wix installer to overwrite(read: modify existing registry values), add new ones etc. Upon uninstall I need to revert them back to their original state (the ones I modified). As this is not supported by Wix and thus I have to use a custom action (as I read) I want to run an exe which will run a .reg file using reg import. According to this site: http://www.installsite.org/pages/en/isnews/200108/index.htm my custom action has to run After="InstallFinalize" because the wix rollback would delete my registry import (as part of the rollback). So essentially it looks like this: Installer modifies reg values, uninstaller deletes all touched registry changes (part of rollback), my exe will restore them.

So I did according to his how to, to start my exe with elevated rights etc. http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html

            <Component Id="registry" Guid="*">
              <File Id="regexe" Source="RegistryRollback.exe"/>
              <File Id="regfile" Source="Reg_rollback.reg" />
            </Component>

<Property Id="LaunchRegExe" Value="[#regexe]" />
<CustomAction Id="LaunchRegExe" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="no"/>

<Custom Action='LaunchRegExe' After='InstallFinalize'>Installed AND NOT UPGRADINGPRODUCTCODE</Custom>

but I get an Error 19 ICE77: LaunchRegExe is a in-script custom action. It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table C:\Merlin\Main\Demo\KioskDemoSetup\nw_setup\nw.wxs 250 1 nw_setup

Thank you for your help!

Stick answered 30/10, 2014 at 19:12 Comment(1)
Not seeing the whole picture here... where do you modify the registry values? Where are you worried about the rollback action reverting your changes? From what we see here, aside from the fact that deferred actions must be run between InstallInitialize and InstallFinalize, your action will only be run on an uninstall, which behaves differently when you cancel it. Means that your exe will only run on uninstall, in deferred context, sometime before the (un)installation is finalized.Issykkul
N
10

According to this site: http://www.installsite.org/pages/en/isnews/200108/index.htm my custom action has to run After="InstallFinalize" because the wix rollback would delete my registry import (as part of the rollback).

Can you specify where is this mentioned on that site? I'm looking at it but can't find a reason why your action should run with After="InstallFinalize".

What it does mention, is that

Deferred, rollback and commit custom actions can only be placed between InstallInitialize and InstallFinalize

Which is the reason for your error: you have a deferred action, but want to run it after installfinalize.

The rollback script would be executed if the installation (or uninstallation) is aborted, for example when canceled by the user. I think you can simply run your action with Before="InstallFinalize".

Novation answered 30/10, 2014 at 20:43 Comment(2)
It is in Installation Execute Sequence. "This second phase is where the target computer is modified, i.e. files are copied, registry entries are written, etc." What I meant with rollback was the rollback of all changes done by the installer, e.g removing installation folder, rolling back changes done to the registry during install (read: delete them). So according to that site I need to run exe afterwards because if not then my exe would restore the registry only to be deleted by wix. Or do I misunderstand something here?Stick
Are these existing registry entries that are being overwritten, or ones created by the installer? In the first case, I'm not sure if they would be removed by the default uninstall... Nevertheless, if you want to ensure that the script is executed after the registry removal step, I think you can just use After='RemoveRegistryValues' (but must be before install finalize, because after that the deferred action cannot be executed). Unfortunately I can't test it at the moment, but based on the documentation it should work.Novation

© 2022 - 2024 — McMap. All rights reserved.