I want to install Java using an NSIS script, but i have to know whether Java is installed or not in the system (Windows). based on the register keys how can we check if Java is installed or not?
Can anybody provide an NSIS script to check Java installation based on registery keys?
Nullsoft Scriptable Install System (NSIS) is a script-driven installer authoring tool for Microsoft Windows backed by Nullsoft, the creators of Winamp. NSIS is released under a combination of free software licenses, primarily the zlib license.
nsi file by simply right-clicking on it in Explorer and selecting 'compile'. If you want to use MakeNSIS on the command line, the syntax of makensis is: makensis [ option | script. nsi | - ] [...]
I didn't compile it, but I would try following. I chose registry key based on How can I detect the installed Sun JRE on Windows?.
;--------------------------------
;Defines
!define JavaRegKey 'HKLM "Software\JavaSoft\Java Runtime Environment" ""'
;--------------------------------
;Installer Sections
Section 'Java Runtime' SecJava
SetOutPath '$TEMP'
SetOverwrite on
File 'c:\<yourdir>\javasetup.exe'
ExecWait '$TEMP\javasetup.exe' $0
DetailPrint '..Java Runtime Setup exit code = $0'
Delete '$TEMP\javasetup.exe'
SectionEnd
;--------------------------------
; Functions
Function .onInit
ReadRegStr $R0 ${JavaRegKey}
StrCmp $R0 "" JavaMissing JavaFound
JavaFound:
!insertmacro UnselectSection ${SecJava}
Goto JavaCheckDone
JavaMissing:
!insertmacro SelectSection ${SecJava}
JavaCheckDone:
FunctionEnd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With