0

I have 2 unwanted processes running: foo.exe and bar.exe, and both have child processes started by them.

I want to use taskkill to terminate all these processes (foo.exe, bar.exe and all child ones). Do I need to use \t parameter only once or do I need to use it multiple times? I.e., which version is correct:

a) taskkill /f /im "foo.exe" /im "bar.exe" /t

b) taskkill /f /im "foo.exe" /t /im "bar.exe" /t

?

john c. j.
  • 725
  • 5
  • 28
  • 81
  • As far as I remember, the `/T` option affects all listed/matching processes, but I cannot test at the moment; I will let you know as soon as I can... – aschipfl Sep 13 '18 at 17:17
  • @aschipfl Very interesting. Let me know! :) – john c. j. Sep 13 '18 at 17:31
  • Meanwhile I had the chance to test: `taskkill` applies the `/T` option for all processes, independent on the position of the switch (I tried with the Acrobat Reader DC process that runs some child processes and with the Windows Calculator, like `taskkill [/T] /PID [/T] /PID [/T]`, with `/T` put before the first, after the last, oir in between the processes, and with Acrobat Reader DC and Calculator on either position, so trying all possible combinations; each time all child processes of Acrobat Reader DC were terminated). – aschipfl Sep 18 '18 at 09:18
  • @aschipfl Thank you very much for this testing. It's a good addition for provided answer. – john c. j. Sep 18 '18 at 11:22
  • You're welcome! By the way, the same is true for the `/F` option, it also affects all matching processes... – aschipfl Sep 18 '18 at 12:47

1 Answers1

2

Well, a for loop will be more meaningful as you can add/remove imagenames as you please:

Using batch file:

@echo off
for %%i in (foo.exe bar.exe) do taskkill /f /im "%%i" /t

From cmdline:

for %i in (foo.exe bar.exe) do taskkill /f /im "%i" /t
Gerhard
  • 22,678
  • 7
  • 27
  • 43