Writing a simple batch file to setup a variable?
Posted
by Sam
on Stack Overflow
See other posts from Stack Overflow
or by Sam
Published on 2010-05-20T02:04:30Z
Indexed on
2010/05/20
2:10 UTC
Read the original article
Hit count: 252
I want to write a simple batch file where i want to setup a environment variable based on the machine architecture. It is as below:
set ARCH=%PROCESSOR_ARCHITECTURE%
echo %ARCH%
if %ARCH%==x86 (
set JAVA_ROOT=C:\Progra~1\Java\j2re1.4.2_13
) else (
set JAVA_ROOT=C:\Progra~2\Java\j2re1.4.2_13
)
echo JAVA_ROOT is %JAVA_ROOT%
On 64-bit machine where the architecture is 'AMD64' the JAVA_ROOT will be displayed as 'C:\Progra~2\Java\j2re1.4.2_13' at the echo statement. But when i run an application that uses this file, the first value of JAVA_ROOT would be picked up 'C:\Progra~1\Java\j2re1.4.2_13'. I don't have any idea why it goes in the 'if' part even though i am running this on 64-bit Windows7. When i echoed the
© Stack Overflow or respective owner