How to kill a process from WiX
Asked Answered
M

2

18

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.

Monofilament answered 11/7, 2012 at 19:13 Comment(2)
Hi @Monofilament how did you solve it? cause i'm doing the same thing as the marked answer but it doesn't work for me. i'm using win 10 thanksOpalina
@ElamirOhana This was years ago and I haven't worked with WiX since, however there is a comment on the selected answer (that worked for me) regarding the new version of WiX, maybe that can help you figure it out: "From the docs, CAQuietExec will be unavailable in 4.0. There are equivalent replacements at the link. – Will"Monofilament
M
36

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"/>
    ...
Monofilament answered 12/7, 2012 at 19:32 Comment(4)
Is there a possiblity to get this working for proecesses which are running with admin rights? Currently this wont work if a process i running at an admin account cause the qtexec has not enough rights to kill the process.Coranto
Be carefull taskkill is not available in the HOME editions of windows.Jackhammer
From the docs, CAQuietExec will be unavailable in 4.0. There are equivalent replacements at the link.Lilialiliaceous
btw, if your app can process the WM_CLOSE message properly, then you don't need to use the /F flag.Embrocation
J
5

I have used the CloseApplication element to do this, if I understand your needs. The processes I killed don't show as applications in Task Manager. Depends on what process class you're talking about, though.

Jennette answered 19/12, 2012 at 19:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.