How to kill a process from WiX

patrickbadley picture patrickbadley · Jul 11, 2012 · Viewed 9.5k times · Source

I am developing an installer using Wix and need to kill a process (not application) silently during installation so the user doesn't get a pop up asking to kill the process or wait and restart. I have seen solutions for killing an application but not a process.

Answer

patrickbadley picture patrickbadley · Jul 12, 2012

After some digging around I found this solution which uses the WixUtilExtension Quiet Execution Custom Action http://wix.sourceforge.net/manual-wix3/qtexec.htm:

<InstallExecuteSequence>
  <Custom Action='MyProcess.TaskKill' Before='InstallValidate'/>
</InstallExecuteSequence>

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

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="WindowsFolder" Name="WINDOWS"/>
    ...