title: InnoSetup: Detect if Java is 32-bit or 64-bit
body: <p>In InnoSetup I run this code:</p>
  
  <pre><code>J32 := ShellExec('', 'java', '-d32 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
  J64 := ShellExec('', 'java', '-d64 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
  </code></pre>
  
  <p>Both <code>J32</code> and <code>J64</code> are <code>True</code>.</p>
  
  <p>In command line:</p>
  
  <pre><code>&gt; java -d32 -version
  Error: This Java instance does not support a 32-bit JVM.
  Please install the desired version.
  
  &gt; echo %errorlevel%
  1
  
  &gt; 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)
  
  &gt; echo %errorlevel%
  0
  </code></pre>
  
  <p>Why does <code>ShellExec()</code> ignore <code>Params</code>?</p>
  
  <p>I tried <code>Exec()</code> also:</p>
  
  <pre><code>// this way
  J32 := Exec('java', '-d32 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
  // and this way
  J32 := Exec('&gt;', 'java -d32 -version', '', SW_HIDE, ewWaitUntilTerminated, ec);
  </code></pre>
  
  <p>They all return <code>True</code>, and <code>ec = 1</code>, despite the fact that I have a 64-bit java.</p>
  
  <p>It seems that <code>Exec</code> and <code>ShellExec</code> return <code>True</code> because they <em>succeed to run</em> <code>java</code>, but they do not track the error code <code>java</code> returns.</p>