geting registry key value problem - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

nruzic
Posts: 3
Joined: Thu Jun 12, 2008 2:55 pm

geting registry key value problem

I want to detect JRE installation folder od target computer so that I can copy some files to it in my installation procedure.

So I add in search page new search task and set location to registry (to find out version of Java installed on target computer):
root: HKEY_LOCAL_MACHINE
key: SOFTWARE\JavaSoft\Java Runtime Environment
name: BrowserJavaVersion
type: Retrieve the raw value
I tested it and retrieve correct result: 1.6.0_06 which is saved in user defined property named BROWSER_JAVA_VERSION

Than I add new search task and set location to registry (to find out path to Java installation on target computer, i.e. "java.home"):
root: HKEY_LOCAL_MACHINE
key: SOFTWARE\JavaSoft\Java Runtime Environment\[BROWSER_JAVA_VERSION]
name: JavaHome
type: The value contains path to a directory
When this is tested no result is retrieved.

I suppose problem is in user defined property BROWSER_JAVA_VERSION because when I set key to SOFTWARE\JavaSoft\Java Runtime Environment\1.6.0_06
correct result is retrieved when tested: C:\Sun\JRE\jre1.6.0_06\

Where is the problem, any suggestions!?
I need to dynamically detect latest java version and corresponding path from registry.

Thanks in advance!
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: geting registry key value problem

Hi,

Windows Installer does not guarantee the order in which the custom actions are executed. Therefore, if you use the result of a search in another search, most likely the new search will not work. The solution for this is to use a custom action. Here is a sample VBScript custom action which does what you need:

Code: Select all

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_ 
    strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\JavaSoft\Java Runtime Environment"
strValue = "JavaHome"

objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each strKey In arrSubKeys
	Session.Property("BROWSER_JAVA_VERSION") = strKey
	strJavaHome = strKeyPath & "\" & strKey
	objReg.GetStringValue HKEY_LOCAL_MACHINE, strJavaHome, strValue, javaPath
	Session.Property("JAVA_PATH") = javaPath
Next
After this custom action is executed the "BROWSER_JAVA_VERSION" property will contain the newest JRE version and the "JAVA_PATH" property will contain its path.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”