title: Unset variable value assigned within if statement inside a nested for loop
body: <p>I am trying to make one batch file to read parameters from the file and pass it to <code>ant</code> for deployment. </p>
  
  <p>I have made the below batch file: </p>
  
  <pre><code>setlocal enabledelayedexpansion
  echo on
  
  IF EXIST "D:\testfile1.txt" (
      echo Do one thing
  
      set string=
      set /p string=&lt; D:\testfile1.txt
      echo value taken from file is %string
  
      for /f "tokens=2,4,6 delims==:" %%G IN ("%string%") DO (
  
          echo %%G %%H %%I
          set env=%%G
          set dom=%%H
          set com=%%I
          echo ENV !env!
          echo DOM !dom!
          echo COM !com!
  
  
          cd D:\kpn_eai\EAI_FIXED\branches\kpn_eai_fixed\fixed\build\scripts
  
          %ANT_HOME%\bin\xanteai deploy %%G %%H %%I
  
      )
  ) ELSE (
      echo Do another thing
  )
  
  endlocal
  </code></pre>
  
  <p>In <code>testfile1.txt</code> I have parameters in below format: </p>
  
  <pre><code>Environment=Env_Name1:Domain=Domain_Name1:Component=Component_name1
  </code></pre>
  
  <p>Parameters are different deployments. When I am running the above code it is giving below output </p>
  
  <pre><code>D:\&gt;echo off
  Do one thing Ant home is C:\tibco\ant\apache-ant-1.9.13
  value taken from file is Environment=Env_name1:Domain=Domain_Name1:Component=Component_name1
  Env_name1 Domain_Name1 Component_name1
  ENV Env_name1
  DOM Domain_Name1
  COM Component_name1
  </code></pre>
  
  <p>Deployments starts after this.</p>
  
  <p>The issue I am facing is when I run this code for different parameters <em>(in <code>testfile1.txt</code>)</em> the values of <code>ENV</code>, <code>DOM</code> and <code>COM</code> remains same regardless of any parameters read from <code>testfile1.txt</code>. </p>
  
  <p>Can anyone help me to correct this code and let me know how can I just assign the values read from file to a variable and pass it to <code>ant</code> for deployment?</p>
  
  <p>NOTE:- This batch file will be placed in scheduler which will check for <code>testfile1.txt</code> after every 5 minutes, when it finds that file deployment process gets triggered. Thus I have included if condition to check availability of file.</p>