/
makelauncher.nsi
66 lines (51 loc) · 1.67 KB
/
makelauncher.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
; This script creates a Java launcher for NodeBox.
Name "NodeBox"
Caption "NodeBox"
Icon "platform\windows\installer\nodebox.ico"
OutFile "dist\windows\nodebox\NodeBox.exe"
RequestExecutionLevel user
SilentInstall silent
AutoCloseWindow true
ShowInstDetails nevershow
!define CLASSPATH "lib\nodebox.jar;lib\jna.jar;lib\iText.jar;lib\asm.jar;lib\jython.jar;lib\mvel.jar;lib\piccolo.jar;lib\xercesImpl.jar"
!define CLASS "nodebox.client.Application"
Section ""
Call GetJRE
Pop $R0
; change for your purpose (-jar etc.)
StrCpy $0 '"$R0" -classpath "${CLASSPATH}" ${CLASS}'
SetOutPath $EXEDIR
Exec $0
SectionEnd
Function GetJRE
;
; returns the full path of a valid java.exe
; looks in:
; 1 - .\jre directory (JRE Installed with application)
; 2 - JAVA_HOME environment variable
; 3 - the registry
; 4 - hopes it is in current dir or PATH
Push $R0
Push $R1
; use javaw.exe to avoid dosbox.
; use java.exe to keep stdout/stderr
!define JAVAEXE "javaw.exe"
ClearErrors
StrCpy $R0 "$EXEDIR\jre\bin\${JAVAEXE}"
IfFileExists $R0 JreFound ;; 1) found it locally
StrCpy $R0 ""
ClearErrors
ReadEnvStr $R0 "JAVA_HOME"
StrCpy $R0 "$R0\bin\${JAVAEXE}"
IfErrors 0 JreFound ;; 2) found it in JAVA_HOME
ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
StrCpy $R0 "$R0\bin\${JAVAEXE}"
IfErrors 0 JreFound ;; 3) found it in the registry
MessageBox MB_OK|MB_ICONSTOP "No Java found. Please download and install Java at www.java.com."
StrCpy $R0 "${JAVAEXE}" ;; 4) wishing you good luck
JreFound:
Pop $R1
Exch $R0
FunctionEnd