title: How to set registry key (environment variable) with value from [Code] section of Inno Setup?
body: <p>I'm creating an installer with Inno Setup, and I need to set the Environment Variable for the user if they didn't set yet. </p>
  
  <p>What I exactly want to achieve is as follows : </p>
  
  <ol>
  <li><p>Detect whether the system has the Environment Variable called "JAVA_HOME" or not.</p></li>
  <li><p>If it already has, then skip the remaining steps. If not, then I will show a page to prompt the user to input the path where they install the JDK, and set to the value of the Environment Variable.</p></li>
  </ol>
  
  <p>And my problem is : How would I set the Environment Variable according to the value input by user? I've searched some articles, and the only way I found to set Environment Variable is like this</p>
  
  <pre><code>[Registry]
  ; set PATH
  Root: HKLM; Subkey: "Environment"; ValueType:string; ValueName:"VARIABLE_NAME"; \
      ValueData:"new_value" ; Flags: preservestringtype ;
  </code></pre>
  
  <p>But obviously, that couldn't achieve what I want to do, because the value must be written "Before" the installer been built. So could any one has any device? Thanks!</p>