: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
Question
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.
Solution
: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
OTHER TIPS
You can also use the following to force kill FF windows:
taskkill /F /FI "ImageName eq firefox.exe"
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.
I do
@echo off
TASKKILL /IM firefox.exe /F
pause>nul
exit
I'm on windows 7, it works for me