title: Windows batch: variables set inside a loop are ignored
body: <p>I'm using the following code inside a Windows batch (*.bat) file to run several SQL queries:</p>
  
  <pre><code>set PSTR=QUERY1,QUERY2
  
  for %%a in (%PSTR%) do (
  
    set START=%date%:%time%
    "C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -f "D:\SQL\%%a.sql" -h localhost -p 5432 -U postgres db_tom
    set END=%date%:%time%
    echo %%a  DEB %DEB%  FIN %FIN% &gt;&gt; "D:\LOGS\log.txt"
  </code></pre>
  
  <p>The echo writes the following string inside the <code>log.txt</code> file:</p>
  
  <pre><code>QUERY1 START END
  QUERY2 START END
  </code></pre>
  
  <p>The variables set inside the loop are ignored. Is there another way to write this batch in order to get start and end datetime written down?</p>