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.
What I exactly want to achieve is as follows :
Detect whether the system has the Environment Variable called "JAVA_HOME" or not.
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.
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
[Registry]
; set PATH
Root: HKLM; Subkey: "Environment"; ValueType:string; ValueName:"VARIABLE_NAME"; \
ValueData:"new_value" ; Flags: preservestringtype ;
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!