title: batch ERRORLEVEL problems
body: <p>I have a file that checks to see if a process is running. If so then it loops, if not it echoes a line into a txt file, My problem is that when the process isn't running it still continues the loop. Here's my code</p>
  
  <pre><code>:a
  Tasklist /v | findstr CMD.exe | findstr LAN 
  If ERRORLEVEL==1 goto :done
  Goto :a
  
  :done
  
  Echo %USERNAME% has logged out. &gt;&gt;log.txt
  </code></pre>
  
  <p>I think I've done something wrong with ERRORLEVEL althought I've tried it with the if and if not statements with errorlevels of 0-2.</p>