Search code examples
processwixkill

How to kill a process from WiX


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.


Solution

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