Archive: How to use Registry Entry?


How to use Registry Entry?
  Hi,

I'm fairly new to NSIS so my apologies if the answer to this question is entirely obvious.

I've spent the last couple of hours reading this forum trying to ascertain an answer to my question to no avail.

I need to read a registry entry containing the installation location of Java.

Then I'd like to use this registry entry to create a shortcut entry that will enable my Java program to run.

In the following code example I read the location and attempt to use it, but neither the FileOpen nor the FileWrite seem to properly use the $1 variable.

Thus, how can I use the $1 variable to create a fully qualified path?

Push $1
ReadRegStr $1 HKLM \
"SOFTWARE\JavaSoft\Java Runtime Environment\1.4\JavaHome" JavaHome

FileOpen $2 "$1\testfile.txt" "w"
FileWrite $2 "HELLO $1"
FileClose $2

BTW, I have successfully detected if Java is installed and the Java version using the IsNT function examples.

Thus, I know I'm on the right track, i.e. I've correctly used the ReadRegStr function in other instances.

I just need a little push to get me over the top.

Thanks for any and all help.

Regards,

OYAHHH


you can use this:


InstallDirRegKey HKLM SOFTWARE\APP TheAppDir
;Since The root exists :p

Thus, how can I use the $1 variable to create a fully qualified path?
If the variable $1 contain spaces (like c:\program files), should be put between the double quotes ["] (, single quotes ['] or backward single quotes [`]) :

ReadRegStr "$1" 

>HKLM "SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.4\\JavaHome" JavaHome
>

You don't need to quote the variable if you wish to read into it. You only need to quote variables if there is a path in it with spaces that you wish to execute or use somewhere Windows will use. For example:


ReadEnvStr $1 COMSPEC

Exec '"$1" /C dir > output.txt'
OYAHHH, you have an extra JavaHome in that command. You are trying to read the JavaHome string value from the "SOFTWARE\JavaSoft\Java Runtime Environment\1.4\JavaHome" key, but the JavaHome string value is inside the "SOFTWARE\JavaSoft\Java Runtime Environment\1.4" key.