Close all firefox tabs with BATCH

Batuhan B picture Batuhan B · Nov 22, 2013 · Viewed 7.6k times · Source

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.

Answer

MC ND picture MC ND · Nov 22, 2013
: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