3

I try to close all firefox if there are more than one. I want to do loop that check the firefox process and close and check again until there is no any firefox process.

This is my code:

:loop
taskkill /im "firefox.exe"
tasklist /fi "imagename eq firefox.exe" goto loop

Where is my wrong in this command ? Any help is appreciated.

Batuhan B
  • 1,835
  • 4
  • 29
  • 39

4 Answers4

3
:loop 
tasklist /fi "imagename eq firefox.exe" | find "firefox.exe" >nul && ( taskkill /im firefox.exe >nul & goto loop )

Get list of tasks, and if firefox.exe included in it, then kill it and goto loop

MC ND
  • 69,615
  • 8
  • 84
  • 126
3

You can also use the following to force kill FF windows:

taskkill /F /FI "ImageName eq firefox.exe" 
Lion
  • 16,606
  • 23
  • 86
  • 148
Saurabh Singhai
  • 253
  • 1
  • 2
  • 9
1

One taskkill command will kill every firefox process - unless it is not responding.

You could use two taskkill commands separated by a delay of several seconds, and the second one should use the /f force switch.

foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • I am using windows xp and taskkill doesn't kill every firefox process. If there are 2 windows for firefox it kills only one window. In the task manager it seems only one process but I don't understand why it does'nt working. Also the answer of @MC works really fine – Batuhan B Nov 22 '13 at 13:53
  • `start notepad.exe & start notepad.exe & taskkill /im notepad.exe` <-- try that command. Only if a process is not responding will it remain in memory, and my answer describes how to solve that. – foxidrive Nov 22 '13 at 14:32
0

I do

@echo off

TASKKILL /IM firefox.exe /F

pause>nul

exit

I'm on windows 7, it works for me

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55