title: Batch file: GOTO in a FOR loop
body: <p>I have a batch file with a FOR loop. In the loop I must wait for a process to end, for which I used IF and GOTO. The problem is the GOTO is breaking the loop. I tried to find other solutions but I didn't find anything. How can it be done?</p>
  <pre><code>@echo off
  for /f &quot;tokens=*&quot; %%a in (file.txt) do (
  bla bla bla
  bla bla bla
  :check
  tasklist /FI &quot;IMAGENAME eq prog.exe&quot; 2&gt;NUL | find /I /N &quot;prog.exe&quot;&gt;NUL
  if &quot;%ERRORLEVEL%&quot;==&quot;0&quot; (goto check)
  )
  </code></pre>