Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSIS script for java installation

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?

like image 755
pmad Avatar asked Feb 15 '11 06:02

pmad


People also ask

What is a Nullsoft installer?

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.

How do you compile NSIS?

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 | - ] [...]


1 Answers

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
like image 150
jing Avatar answered Sep 18 '22 17:09

jing