Kill my application during uninstall

2

I have run into challenging problem trying to accomplish the following: my application installs a service (watchdog.exe) and an exe file (app.exe).

After the installation is done the service starts and creates process "app.exe".

during uninstall I want to kill the process "app.exe" (which is running under local system account, so I must be running as admin).

problem 1: The installs says that it requires a reboot since it sees that file "app.exe" is being held (running) during the CostFinalize phase (please correct me if I'm wrong about the phase that checks if a reboot will be required). It would be much better to kill the process when the uninstallation begins. I have verified that if the process is not running during the uninstall then the install does not complain about a reboot required.

problem 2: using a custom action to kill the process is problematic. the action must run elevated, but on the other hand it must run before the costFinalize (otherwise - it's back to problem 1).

I would appreciate any suggestion. Also, any alternative solutions (is there another way to close the process maybe during install that will not require a reboot?)

The custom action code I have now (not good since it both unnecessarily asks for a reboot and fails to kill the process due to lack of permissions):

<InstallExecuteSequence>
  <!--<ScheduleReboot After="InstallFinalize" />-->
  <Custom Action="MyProcess.TaskKill" Before="InstallValidate"></Custom>
</InstallExecuteSequence>

<!--<Property Id="Net">Net.exe</Property>-->
<Property Id="QtExecCmdLine" Value='"[%SYSTEMROOT]\System32\taskkill.exe" /F /IM App.exe' />
<CustomAction Id="MyProcess.TaskKill"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="immediate"
              Return="ignore" />

Here is the log for the failure:

CAQuietExec: Error 0x80070001: Command line returned an error. CAQuietExec: Error 0x80070001: CAQuietExec Failed CustomAction MyProcess.TaskKill returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 18:15:54: MyProcess.TaskKill. Return value 1603.

wix
asked on Stack Overflow Nov 11, 2013 by OSH • edited Nov 11, 2013 by Steven V

1 Answer

1

There are few ideas that I have, namely:

  • Use EventWaitHandles, which allow processes to communicate between each other, and delegate your wish to app.exe. Your app.exe can then terminate, as needed. This is clean solution and should be prefered.

If for whatever reason you decide to kill the application like you don't care about anything at all in the world, then you can:

Basically there are so many hackery tricks you can do, to kill the application. Such as using WiX Burn and requiring administration rights, then doing your thing. I would go with solution#1(create your own mechanisms)

By the way, if you use ServiceControl element in WiX, it will STOP the service before REINSTALLING/UNISTALLING. You can hook to OnStop() method in Service and kill your App.exe there. If you have set Service as App.exe parent, then there should be flag that any child processes die with parent.

answered on Stack Overflow Nov 11, 2013 by Erti-Chris Eelmaa • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0