Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 332
sceiler Avatar asked Feb 11 '23 16:02

sceiler


1 Answers

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".

like image 67
Akos Bannerth Avatar answered Mar 03 '23 05:03

Akos Bannerth