Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

It seems that you have misunderstood my explanation. Note that the custom action i mentioned is an example. You need to modify it to suit your needs.

Here is a custom action which does what you need:

Code: Select all

const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
 strComputer & "\root\default:StdRegProv")
 
 'find newest JRE version
strKeyPath = "SOFTWARE\JavaSoft\Java Runtime Environment\"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
 
For Each subkey In arrSubKeys
newest_version=subkey
Next
 
Session.Property("JAVA_NEWEST_VERSION")=newest_version

'find the path
strKeyPath = "SOFTWARE\JavaSoft\Java Runtime Environment\" & newest_version
strValueName = "JavaHome"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

Session.Property("JAVA_HOME_PATH")=strValue
After this custom action runs, the JAVA_NEWEST_VERSION property will contain the latest JRE version installed on the target machine and the JAVA_HOME_PATH property will contain its path.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Hi Cosmin, thanks for the details. I've pasted your code into a file called GetCurrJavaVer.vbs. Unfortunately when I run the installer I still get the script error when the script completes.

I ran the installer with logging, and this is the last few lines of the log (and there is no mention of any error):

Code: Select all

MSI (s) (E0:88) [17:17:45:656]: Doing action: GetCurrJavaVer.vbs
Action 17:17:45: GetCurrJavaVer.vbs. 
Action start 17:17:45: GetCurrJavaVer.vbs.
MSI (s) (E0!88) [17:17:45:703]: PROPERTY CHANGE: Adding JAVA_NEWEST_VERSION property. Its value is '1.6.0_03'.
MSI (s) (E0!88) [17:17:45:718]: PROPERTY CHANGE: Adding JAVA_HOME_PATH property. Its value is 'C:\Program Files (x86)\Java\jre1.6.0_03'.
The script looks to be doing the right thing, but after adding of the property JAVA_HOME_PATH it's crashing the installer??
Any ideas? Phil
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi Phil,

I'm not sure how exactly you are using this script in your project. Can you please send us the AIP which shows this behavior to support at advancedinstaller dot com so we can investigate it?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Have just emailed it, thanks
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Hi,
I'd just like to say a big public thank you to Cosmin for helping us through our installer issues. Some of the problems were in the way we'd set up some custom actions (and interpretation of how we were meant to do it), but also Cosmin's help in getting the vb script working correctly was great.

Thanks once again,
Phil
mikejwatts
Posts: 5
Joined: Fri Apr 03, 2009 2:17 pm

Re: adding files to current JRE

Hi All,
I used the VBS script seen in several pages of this forum and sure enough, the message box pops up with the current JRE home. Problem I have is getting the variable into the installer: it always creates a directory C:\JAVA_HOME!

In the Custom Actions page, the action is set to Immediate and is in the InstallExecuteSequence -> InsallInitialize stage. Function Name is blank, Action Data I have tried making this blank, [JAVA_HOME], [JAVA_HOME]=Session.Property("JAVA_HOME") [which is what I named it in the script] and maybe a few other attempts. Help!

I would agree that it would be useful to be able to have a search ( which would have worked a treat some hours ago ;-) ) which could depend on another search... and these are easily tested with the toolbar button rather than build install/run install/check the outcome/uninstall sequence.

Mike Watts
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: adding files to current JRE

Hi Mike,

Assuming you used the sample code in this thread for your custom action, the property REG_VALUE should contain the JRE path. This property can be used in the installer the way you need. If you want, you can modify it in the code of the custom action to "JAVA_HOME".
In the Custom Actions page, the action is set to Immediate and is in the InstallExecuteSequence -> InsallInitialize stage.
If you want to use the property for a property-based folder you can schedule the custom action under "InstallExecuteSequence" -> "Begin". This way the path of the property-based folder is set correctly.
Action Data I have tried making this blank, [JAVA_HOME], [JAVA_HOME]=Session.Property("JAVA_HOME") [which is what I named it in the script] and maybe a few other attempts.
For this custom action the "Action Data" field should be left empty. The custom action sets an installer property which can be used in the install process.

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

Return to “Common Problems”