title: Batch script set command not working properly
body: <p>I am trying to read the first line from a file and I am setting it as environment variable. Below is the variable I use</p>
  <pre><code>@echo off
  if EXIST &quot;test.dat&quot; (
      set JAVA_HOME_PATH=
      set JAVA_PATH=
      set /p JAVA_HOME_PATH=&lt;test.dat
      echo %JAVA_HOME_PATH%
      set JAVA_PATH=%JAVA_HOME_PATH%\bin\java
      echo %JAVA_PATH%
    )
  </code></pre>
  <p>Assuming the test.dat contains the path to JDK and if it is c:\JDK1.6</p>
  <p>on running it for the first time I get</p>
  <pre><code>ECHO is off.
  ECHO is off.
  </code></pre>
  <p>on running again I get</p>
  <pre><code>c:\JDK1.6
  \bin\java
  </code></pre>
  <p>and on running again I get</p>
  <pre><code>c:\JDK1.6
  c:\JDK1.6\bin\java
  </code></pre>
  <p>I dint change the test.dat file. But why is this happening ? Only when I run for third time all the variables getting set ? Looks weird. Am I doing anything wrong in this?</p>