Search code examples
batch-filecmdtaskkill

Taskkill: Do I need to specify \t parameter multiple times?


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

?


Solution

  • 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