title: CMD how to use if and tasklist with find /C
body: <p>Anyone knows how to use <strong>IF</strong> and <strong>tasklist</strong> with <strong>find /C</strong>. 
  I want to compare running instances or certain application to predefined number.</p>
  
  <p>Application name= test.exe</p>
  
  <p>number of instances that should run=2 (If there are less then do stuff else report OK)</p>
  
  <p>Here is my doo-bey-doo so far:</p>
  
  <pre><code>tasklist /FI "IMAGENAME eq test.exe" | find /I /C "test.exe"
  </code></pre>
  
  <p>This works great. I get the correct figure of running instances. But when I put it into IF sentence in a BATCH file that's where the hell breaks loose. So where I go wrong here?</p>
  
  <pre><code>if tasklist /FI "IMAGENAME eq test.exe" | find /I /C "test.exe" EQU 2 : ECHO OK
  
  ELSE ( GOTO doStuff )
  
  :doStuff
  </code></pre>