2
votes

I'm using Wix to create an.msi installation file. when I uninstall my application, it's somehow still working and I can see it in the task manager.

I've tried Deferred execution for a custom action as described in the Wix documentation: https://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html but unfortunately, it's not working with me. the command that I want to execute is "taskkill /f /im myProcess.exe"

<Property Id="myProcessKill" Value="taskkill /f /im myProcess.exe"/>
<CustomAction Id="myProcessKill" BinaryKey="WixCA" DllEntry="WixQuietExec"
            Execute="deferred" Return="check" Impersonate="no"/>

<InstallExecuteSequence>
  <Custom Action="myProcessKill" After="InstallValidate"/>
</InstallExecuteSequence>

this makes my msi file gives an error during the installation. and if i changed Return="check" to Return="ignore", the msi completes the installation but it doesn't kill my process upon uninstall. what's wrong with the code above? or is there any other way to kill my process upon un install? Thanks in advance

2
Maybe have a read on the Restart Manager feature. And there is a more detailed version here (see section "Setup Overkill"). - Stein Åsmul
I haven't checked this in detail for uninstall scenarios, but it should be worth a read. Restart Manager essentially closes applications in a controlled way, saving data as appropriate. - Stein Åsmul
@SteinÅsmul Thanks for your comment but i don't want to reboot after uninstall do you know another solution - Elamir Ohana
It wasn't about the rebooting, it was about the controlled shutdown of the application and the potential to restart it using the Restart Manager feature. I am not sure if it works properly on uninstall. See this technical piece from Advanced Installer. It is better to have your application shut itself down gracefully than to kill it. - Stein Åsmul

2 Answers

2
votes

Maybe try: WiX's CloseApplication Element. I would try that before trying anything else to avoid dependencies to any binaries. Found this sample on github.com (untested).

2
votes

Try to use cmd.exe with quotes and pass taskkill to that, in your case

<Property Id="myProcessKill" Value="&quot;c:\windows\system32\cmd.exe&quot; /c taskkill /f /im myProcess.exe"/>

I'm also not sure about your custom action in sequence, at least your should add REMOVE="ALL". In our app we are using <Custom Action="CloseApplication" Before="InstallInitialize"> <![CDATA[ NOT UPGRADINGPRODUCTCODE AND REMOVE="ALL" ]]> </Custom>