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
@echo off
if EXIST "test.dat" (
set JAVA_HOME_PATH=
set JAVA_PATH=
set /p JAVA_HOME_PATH=<test.dat
echo %JAVA_HOME_PATH%
set JAVA_PATH=%JAVA_HOME_PATH%\bin\java
echo %JAVA_PATH%
)
Assuming the test.dat contains the path to JDK and if it is c:\JDK1.6
on running it for the first time I get
ECHO is off.
ECHO is off.
on running again I get
c:\JDK1.6
\bin\java
and on running again I get
c:\JDK1.6
c:\JDK1.6\bin\java
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?
%in the filename on the first line?c:\>test.bat