Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / altosui / Instdrv / NSIS / Includes / java.nsh
1 !include WordFunc.nsh
2
3 ; Definitions for Java Detection
4
5 !define JRE_VERSION "1.6"
6 !define JRE32_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52247&/jre-6u27-windows-i586.exe"
7 !define JRE64_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52249&/jre-6u27-windows-x64.exe"
8
9 Var JavaDownload
10 Var JavaBits
11
12 Function GetJRE
13         ${If} ${RunningX64}
14            StrCpy $JavaDownload ${JRE64_URL}
15            StrCpy $JavaBits "64"
16         ${Else}
17            StrCpy $JavaDownload ${JRE32_URL}
18            StrCpy $JavaBits "32"
19         ${EndIf}
20
21         MessageBox MB_OK "This product uses Java ${JRE_VERSION}, \
22                         $JavaBits bits, it will now \
23                         be downloaded and installed"
24
25         StrCpy $2 "$TEMP\Java Runtime Environment.exe"
26         nsisdl::download /TIMEOUT=30000 $JavaDownload $2
27         Pop $R0 ;Get the return value
28                 StrCmp $R0 "success" +3
29                 MessageBox MB_OK "Download failed: $R0"
30                 Quit
31         ExecWait $2
32         Delete $2
33 FunctionEnd
34
35 Function DetectJRE
36   ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \
37              "CurrentVersion"
38
39   DetailPrint "Desired Java version ${JRE_VERSION}"
40   DetailPrint "Actual Java version $2"
41
42   ${VersionCompare} $2 ${JRE_VERSION} $3
43
44   IntCmp $3 1 done done
45
46   Call GetJRE
47
48 done:
49
50 FunctionEnd