Here is something I had put together quite a while ago that works for me.
You should be able to modify it to do what you need.  You could change the
CustomAction to SetProperty elements.



<Condition Message="!(loc.Java160MustBeInstalled)">JAVA_JRE_HOME</Condition>

<Property Id="JAVA_JDK_CURRENT_VERSION"/>
<Property Id="JAVA_JRE_CURRENT_VERSION"/>
<Property Id="JAVA_JDK_HOME"/>
<Property Id="JAVA_JRE_HOME"/>
<Property Id="JAVA_JDK_VERSION">
  <RegistrySearch Id="SUN_JDK_VERSION" Root="HKLM"
                  Key="SOFTWARE\Javasoft\Java Development Kit"
                  Name="CurrentVersion" Type="raw"/>
</Property>
<Property Id="JAVA_JRE_VERSION">
  <RegistrySearch Id="SUN_JRE_VERSION" Root="HKLM"
                  Key="SOFTWARE\Javasoft\Java Runtime Environment"
                  Name="CurrentVersion" Type="raw"/>
</Property>

<CustomAction Id="SetJavaJDKCurrentVersion"
Property="JAVA_JDK_CURRENT_VERSION"
             Value="HKLM\SOFTWARE\Javasoft\Java Development
Kit\[JAVA_JDK_VERSION]"/>
<CustomAction Id="SetJavaJRECurrentVersion"
Property="JAVA_JRE_CURRENT_VERSION"
             Value="HKLM\SOFTWARE\Javasoft\Java Runtime
Environment\[JAVA_JRE_VERSION]"/>

<InstallUISequence>
   <Custom Action="SetJavaJDKCurrentVersion" Before="FindRelatedProducts"/>
   <Custom Action="SetJavaJRECurrentVersion"
After="SetJavaJDKCurrentVersion"/>
   <Custom Action="SetJavaJdkJreHome" After="SetJavaJRECurrentVersion"/>
</InstallUISequence>


 <?include ..\..\build\SetJavaJdkJreHomeVBS.wxi?>
 SetJavaJdkJreHomeVBS.wxi:
      <?xml version="1.0" encoding="UTF-8"?>
      <Include xmlns="http://schemas.microsoft.com/wix/2006/wi";>
            <!-- Set the Java JDK and JRE home directory properties -->
            <CustomAction Id="SetJavaJdkJreHome" Script="vbscript">
      <![CDATA[
               jdkCurrentVersion =
Session.Property("JAVA_JDK_CURRENT_VERSION")
               jreCurrentVersion =
Session.Property("JAVA_JRE_CURRENT_VERSION")

               defaultVer = "1.6"
               defaultValue = "notset"

               jdkHomeKey = jdkCurrentVersion & "\JavaHome"
               'MsgBox "Java JDK Home Reg Key = " & jdkHomeKey, vbOkOnly
               jdkHome = readfromRegistry(jdkHomeKey, defaultHome)

               jreHomeKey = jreCurrentVersion & "\JavaHome"
               'MsgBox "Java JRE Home Reg Key = " & jreHomeKey, vbOkOnly
               jreHome = readfromRegistry(jreHomeKey, defaultHome)

               ' Only set the properties if a value was found in the
registry
               if jdkHome <> defaultValue then
                  Session.Property("JAVA_JDK_HOME") = jdkHome
               end if
               if jreHome <> defaultValue then
                  Session.Property("JAVA_JRE_HOME") = jreHome
               end if

               function readFromRegistry (strRegistryKey, strDefault )
                  Dim WSHShell, value
                  On Error Resume Next

                  Set WSHShell = CreateObject("WScript.Shell")
                  value = WSHShell.RegRead( strRegistryKey )
                  'MsgBox "SetJavaJdkJreHome" & vbCrLf & _
                  '       "  Registry key to read: " & strRegistryKey &
vbCrLf & _
                  '       "  Default value: " & strDefault & vbCrLf & _
                  '       "  Value read: '" & value & "'" & vbCrLf & _
                  '       "  err.number = " & err.number, vbOkOnly

                  if err.number <> 0 then
                     readFromRegistry= strDefault
                  else
                     readFromRegistry=value
                  end if

                  set WSHShell = nothing
               end function
      ]]>
            </CustomAction>
      </Include>


On Thu, Jan 12, 2012 at 4:27 PM, Christopher Painter <chr...@iswix.com>wrote:

> My memory of the way Java stores there version information in the registry
> isn't very friendly to MSI's RegLocator pattern.  You might need a custom
> action.
>
> ----------------------------------------
>
> From: "T. Kuro Kurosaka" <k...@basistech.com>
>
> Sent: Thursday, January 12, 2012 6:21 PM
>
> To: wix-users@lists.sourceforge.net
>
> Subject: [WiX-users] Writing JDK version verification code, and Wix
> debugging tip
>
>
> Wix & MSI newbie here.
>
>
> My product requires JDK 1.6 installation, and I'm trying to come up with
>
> Wix code to verify the system has JDK 1.5 installed before proceeding
>
> installation of my product.
>
>
> I thought this would work:
>
>
> <Property Id="JDKVER">
>
> <RegistrySearch Id="NetFramework20"
>
> Root="HKLM"
>
> Key="SOFTWARE\JavaSoft\Java Development Kit"
>
> Name="CurrentVersion"
>
> Type="raw" />
>
> </Property>
>
>
> <Condition Message="This application requires Java Developer Kit 1.5 (or
>
> higher).">
>
> <![CDATA[Installed OR (JDKVER << "1.5" )]]> <!-- test with 1.6, 1.7,
>
> 1.8, etc. will be added later. -->
>
> </Condition>
>
>
> But this didn't work.  Even if JDK 1.5 is installed, this message is
>
> displayed.
>
>
> Anybody has experience doing JDK version check?
>
>
> In an attempt to debug this, I wanted to display the value of property
>
> "JDKVER", and inserted this code.  This is a modified version of the
>
> code I've found in the Internet:
>
> <CustomAction Id="ShowProperty" Script="vbscript" Execute="immediate">
>
> <![CDATA[
>
> MsgBox "JDKVER =" + Session.Property("JDKVER")
>
> ]]>
>
> </CustomAction>
>
>
> <InstallExecuteSequence>
>
> <Custom Action="ShowProperty" Before="InstallFinalize">True</Custom>
>
> <!-- "Not Installed" didn't work either. -->
>
> </InstallExecuteSequence>
>
>
> But no popup came out.  What am I doing wrong here?
>
>
> Thank you in advance.
>
>
> T. "Kuro" Kurosaka
>
>
>
> ----------------------------------------------------------------------------
> --
>
> RSA(R) Conference 2012
>
> Mar 27 - Feb 2
>
> Save $400 by Jan. 27
>
> Register now!
>
> http://p.sf.net/sfu/rsa-sfdev2dev2
>
> _______________________________________________
>
> WiX-users mailing list
>
> WiX-users@lists.sourceforge.net
>
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
>
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Mar 27 - Feb 2
> Save $400 by Jan. 27
> Register now!
> http://p.sf.net/sfu/rsa-sfdev2dev2
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
>

The information contained in this transmission contains potentially privileged, 
export controlled and/or confidential 
information of Imageware Systems, Inc. or its customers or partners.  It is 
intended only to be read by the person(s) 
named above and for no other purpose.  You are hereby notified that any 
dissemination, distribution, duplication of this 
communication or use of its contents for any purpose not authorized expressly 
by Imageware Systems, Inc. is strictly 
prohibited and could lead to both civil and/or criminal penalties.  If you are 
not the intended recipient, you are 
prohibited to review the contents herein and please contact the sender by reply 
e-mail and destroy all copies of the 
original message.  To reply to our e-mail administrator directly, please send 
an e-mail to emailad...@iwsinc.com
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to