title: Batch file if statement fail
body: <p>I am trying to just see if an application is currently running based on the Image Name in the task manager or tasklist... I am using firefox.exe as the example but it always fails. The goal is to not launch another script if its already running and/or to taskkill it when we need.</p>
  
  <p>This is my current status script:</p>
  
  <pre><code>@echo off
  set STATUS=
  FOR /F "tokens=*" %%A IN ('tasklist ^| findstr "firefox.exe"') DO SET STATUS=%%A
  echo %STATUS%
  if [%STATUS%]==[] set STATUS=stopped
  
  echo %STATUS%
  </code></pre>
  
  <p>Always gives the following output: (it always fails on the if statement)</p>
  
  <pre><code>firefox.exe                   6216 Console                    1    411,760 K
  6216 was unexpected at this time.
  </code></pre>
  
  <p>Do you have an idea why this is or suggest another way to go about achieve this?</p>