WiX Toolset - CustomAction for uninstall running after RemoveFiles

1

On install I add a configuration key to a DB using a command line tool. On uninstall, I'm now trying to remove that configuration key. On an upgrade, I need to remove then add the configuration key back.

Here's my CustomAction "redacted" code:

<CustomAction Id="Unset_AppName_Version_Cmd"
              Property="Unset_AppName_Version"
              Execute="immediate"
              Value="&quot;[SystemFolder]cmd.exe&quot; /C &quot;&quot;[SOMEDIR]SomeClTool&quot; &quot;uninstall:appname&quot;&quot;" />

<CustomAction Id="Unset_AppName_Version"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="immediate"
              Return="check"
              Impersonate="yes" />

Note: I've tried several values for execute, including oncePerProcess, firstSequence, and immediate.

Here's my InstallExecuteSequence "redacted" code:

<Custom Action="Unset_AppName_Version_Cmd" Sequence="1215">
    (!AppName = 3 AND (&amp;AppName = 3 OR &amp;AppName = 2))     
</Custom>
<Custom Action="Unset_AppName_Version" Sequence="1216">
    (!AppName = 3 AND (&amp;AppName = 3 OR &amp;AppName = 2))
</Custom>

Note: Again, I tried to move around the sequence used. In the above example before InstallValidate, but also before RemoveFiles, RemoveODBC, etc.

Nothing has worked for me. In all instances, the

Executing op: ActionStart(Name=Unset_AppName_Version,,)

line is being run after RemoveFiles, so my custom action fails with:

CAQuietExec:  The system cannot find the path specified.
CAQuietExec:  Error 0x80070001: Command line returned an error.
CAQuietExec:  Error 0x80070001: CAQuietExec Failed

After this, my installation gets rolled back.

Also, is this condition correct for run on uninstall or reinstall?

(!AppName = 3 AND (&amp;AppName = 3 OR &amp;AppName = 2))

Thanks

Update 7/31/2015

While I still do not have a working solution, I have made enough changes that it makes sense to post my current code.

Here's my updated CustomAction "redacted" code:

<CustomAction Id="Unset_AppName_Version_Cmd" 
              Property="QtExecCmdLine"
              Value="&quot;[SystemFolder]cmd.exe&quot; /C &quot;&quot;[SOMEDIR]SomeClTool&quot; &quot;uninstall:appname&quot;&quot;"
              Execute="immediate" />

<CustomAction Id="Unset_AppName_Version"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="immediate"
              Return="ignore" />

Note: These changes were made based on Kiran's much appreciated suggestions and to mimic some taskkill commands that are working for me.

Example of working code:

<CustomAction Id="TaskKill_erl_exe_Cmd"
              Property="QtExecCmdLine"
              Value='"[SystemFolder]taskkill.exe" /F /IM erl.exe /T'                  
              Execute="immediate" />

<CustomAction Id="TaskKill_erl_exe"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="immediate"
              Return="ignore"/>

Thanks

wix
sequence
custom-action
asked on Stack Overflow Jul 28, 2015 by sleon • edited Jul 31, 2015 by sleon

2 Answers

1

Couple of things here.

-You are trying to execute the custom action in immediate mode using the Wix provided inbuilt Quiet Execution Custom Action.

http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html

If you want to make use of CAQuietExec in immediate mode, the documentation clearly suggests that you have to set the WixQuietExecCmdLine property.

I dont see that being done in your case.

In your case, i see that you are setting a property named Unset_AppName_Version in the immediate mode. This just wont work.

-If you are trying to use CAQuietExec in deferred mode, your authoring of the custom actions in the pasted code snippet will work, as that would lead to populating the value of the inbuilt special property "CustomActionData"

-If the command line tool that you are trying to launch is installed by the msi package, then the custom action with Id="Unset_AppName_Version" has to be sequenced after "InstallFiles" standard action for the case of Install/Upgrade/Re-install.

For the case of uninstall, i am assuming you will have a seperate custom action which invokes this command line tool with a different set of parameters and it should be sequenced before "RemoveFiles" standard action.

-Finally, yes your condition is correct and will invoke the action on re-install or uninstall of the feature.

-Also when you run your msi package, if you want to confirm if the command line tool was indeed launched, you can have a utility named "ProcessMonitor" running. ProcessMonitor is from the Sysinternals suite. Keep the tool running by setting the appropriate filters. If your tool is ever launched, ProcessMonitor will indicate the same to you.

Hope this helps.

answered on Stack Overflow Jul 30, 2015 by Kiran Hegde
0

This ended up working for me:

<CustomAction Id="Unset_AppName_Version_Cmd" 
              Property="QtExecCmdLine"
              Value="&quot;[SystemFolder]cmd.exe&quot; /C &quot;&quot;[SOMEDIR]SomeClTool&quot; &quot;uninstall:appname&quot;&quot;"
              Execute="immediate" />

<CustomAction Id="Unset_AppName_Version"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="immediate"
              Return="ignore" />

And in the InstallExecuteSequence:

<Custom Action="Unset_AppName_Version_Cmd" Sequence="1215">
    (!AppName = 3 AND (&amp;AppName = 3 OR &amp;AppName = 2))     
</Custom>
<Custom Action="Unset_AppName_Version" Sequence="1216">
    (!AppName = 3 AND (&amp;AppName = 3 OR &amp;AppName = 2))
</Custom>

The issue seems to be that something got messed up in my VM with all the rollbacks.

The main problem that I had was that I initially tried to name the property in the "Unset_AppName_Version_Cmd" CustomAction.

Thanks again to Kiran for all his help.

answered on Stack Overflow Aug 5, 2015 by sleon

User contributions licensed under CC BY-SA 3.0