title: Windows batch file looping Wait animation during processing command
body: <p>I have created the following batch file that makes Wait "| / -- \" animation. I want to use it during processing mysql restore database command <code>mysql -u %DBuser% -p %DB% &lt; "%thefile%"</code> <em>where <code>thefile</code> is the sql dump file path</em></p>
  
  <pre><code>@Echo OFF
  setlocal EnableDelayedExpansion
  for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
  SET p=-1
  set num=1
  set "st[1]=| "
  set "st[2]=/ "
  set "st[3]=--"
  set "st[4]=\ "
  
  if /i %p% lss 0 (
  set p=2
  call :LOOP
  call :DoSomeThing
  )
  :LOOP
  if /i %num% lss 4 (
  set /a num=num+1
  ) else (
  set num=1
  )
  &lt;nul set /P "=Wait !st[%num%]!!CR!"
  
  TIMEOUT /T 1 &gt;NUL
  GOTO :LOOP
  
  :DoSomeThing
  TIMEOUT /T 10 &gt;NUL
  echo Doing...
  </code></pre>
  
  <p>Here, <code>:DoSomeThing</code> is for testing purposes and It should be replaced or include the mysql command. I get the problem that <code>:LOOP</code> works for ever and there is no call to <code>:DoSomeThing</code></p>
  
  <p>I tried to call <code>:DoSomeThing</code> before call <code>:LOOP</code> but the LOOP started after DoSomeThing is finished so it becomes useless! Is there any way to make the DoSomeThing or the MySQL command works in the background while the animation wait loop works too? </p>