In InnoSetup I run this code:
J32 := ShellExec('', 'java', '-d32 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
J64 := ShellExec('', 'java', '-d64 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
Both J32 and J64 are True.
In command line:
> java -d32 -version
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.
> echo %errorlevel%
1
> java -d64 -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
> echo %errorlevel%
0
Why does ShellExec() ignore Params?
I tried Exec() also:
// this way
J32 := Exec('java', '-d32 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
// and this way
J32 := Exec('>', 'java -d32 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
They all return True, and ec = 1, despite the fact that I have a 64-bit java.
It seems that Exec and ShellExec return True because they succeed to run java, but they do not track the error code java returns.
 
     
     
    