${EndIf}
!macroend
-; Find any installed JRE/JDK and return the version or -1
-Function DetectJava
- ; FYI: Because it appears there won't ever be a 64 bit version of makensis for linux
- ; this script assumes that it will always be run as part of a 32 bit installer.
- ; If that should ever change this script will require some significant adjustment.
-
- ; 32 bit JRE >= 9
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\JRE" "CurrentVersion"
- StrCmp $0 "" +1 Found
-
- ; 32 bit JDK >= 9
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\JDK" "CurrentVersion"
- StrCmp $0 "" +1 Found
-
- ; 64 bit JRE >= 9
- ${If} ${RunningX64}
- SetRegView 64
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\JRE" "CurrentVersion"
- SetRegView 32 ; basically SetRegView Default since NSIS only creates 32 bit installers
- StrCmp $0 "" +1 Found
- ${EndIf}
-
- ; 64 bit JDK >= 9
- ${If} ${RunningX64}
- SetRegView 64
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\JDK" "CurrentVersion"
- SetRegView 32
- StrCmp $0 "" +1 Found
- ${EndIf}
-
- ; 32 bit JRE < 9
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
- StrCmp $0 "" +1 Found
-
- ; 32 bit JDK < 9
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
- StrCmp $0 "" +1 Found
-
- ; 64 bit JRE < 9
- ${If} ${RunningX64}
- SetRegView 64
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
- SetRegView 32
- StrCmp $0 "" +1 Found
- ${EndIf}
-
- ; 64 bit JDK < 9
- ${If} ${RunningX64}
- SetRegView 64
- ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
- SetRegView 32
- StrCmp $0 "" +1 Found
- ${EndIf}
-
- ; Nuthin.
- Push "-1"
- Return
-
- Found:
- Push $0
- Return
-FunctionEnd
-
function .onInit
setShellVarContext all
!insertmacro VerifyUserIsAdmin
;-----------------
;Check our version
function ValidateInstall
- Call DetectJava
- Pop $0
- StrCmp $0 "-1" NoJava
- ${If} $0 S< ${JRE_MIN_VERSION}
- MessageBox MB_OK "Please update Java to version ${JRE_MIN_VERSION} or higher. Setup will now exit." /SD IDOK IDOK QUIT
- ${EndIf}
; Hatch Version Check
ReadRegStr $1 HKLM "SOFTWARE\${COMPANYNAME}\${APPNAME}" "Version"
StrCmp $1 "" INSTALL
ExecWait '"$TEMP\Uninstall ${APPNAME}.exe" /S _?=$1'
Delete /REBOOTOK "$TEMP\Uninstall ${APPNAME}.exe"
Goto INSTALL
- NoJava:
- MessageBox MB_OK|MB_ICONSTOP "Java Not Detected. Please install a JRE of version ${JRE_MIN_VERSION} or greater." /SD IDOK
QUIT:
Quit
INSTALL: