Archive: How can I check enviroment variable is installed?


How can I check enviroment variable is installed?
In my project, I need to create an environment to set up my application. How can I create script with these requests?
" Right click on My Computer go to the “Advanced” tab and then select “Environment Variables” under “SystemVariables” check if JAVA_HOME is defined. If it isn’t click New and then in the Variable Name type JAVA_HOME and in Variable Value put the location of your Java SDK directory
-Then click New again, and type Variable Name as
MERLIN_HOME and in Variable Value put the location of your merlin directory, which in this case will be “C:\merlin”. "
Somebody can help me!!! :)
Thank a lots,


To read environment variables, use ReadEnvStr. To set them, use one of the solutions available on the wiki.


Thank you for your reply,
I do it well.However,If my environment variable is flexible what will happen?
Eg:
My code :
Section "AddEnvJAVA_HOME"
Push "JAVA_HOME"
Push "C:\Program Files\Java\jdk1.5.0_08"
Call WriteEnvStr
SectionEnd
if user do not install in this directory, how can I know this?


You can push variables as well. Find out the directory where Java is installed and push that instead of the constant string.


Thank Kichik,
I also think use SearchPath to find directory but I still have problem.
If I use SearchPath.When I search file java.exe, the default path is
"C:\Program Files\Java\jdk1.5.0_08\bin\java.exe"
but I only need
"C:\Program Files\Java\jdk1.5.0_08"
I also look for command to cut string but not this.
I am worry about my searchpath command because file "java.exe" also in directory "C:\Program Files\Java\jre1.5.0_08\bin". So, searchpath will wrong and can not set environment variable.
Can you have another opinion???


I already answered that in your other thread. Use GetParent.


Thank Kichik