This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
;------------------ | ||
; ${socket.name} Launcher | ||
;------------------ | ||
; Creates a ${build.socket.name}.exe launcher which performs automatic JRE detection | ||
|
||
!include x64.nsh | ||
!include LogicLib.nsh | ||
!addincludedir "${windows.nsis.addons}/Include" | ||
!include StdUtils.nsh | ||
|
||
; Run this exe as non-admin | ||
RequestExecutionLevel user | ||
|
||
; Application information | ||
Name "${socket.name}" | ||
Caption "${socket.name}" | ||
Icon "${basedir}\${branding.dir}\${windows.icon}" | ||
OutFile "${build.socket.name}.exe" | ||
|
||
SilentInstall silent | ||
AutoCloseWindow true | ||
ShowInstDetails nevershow | ||
|
||
; Full path to jar | ||
!define JAR "$INSTDIR\${build.socket.name}.jar" | ||
|
||
Section "" | ||
${If} ${RunningX64} | ||
${DisableX64FSRedirection} | ||
${EndIf} | ||
Call FindJRE | ||
Pop $R0 | ||
|
||
; change for your purpose (-jar etc.) | ||
StrCpy $0 '"$R0" -jar "${JAR}"' | ||
|
||
SetOutPath $EXEDIR | ||
|
||
Exec $0 | ||
${If} ${RunningX64} | ||
${EnableX64FSRedirection} | ||
${EndIf} | ||
SectionEnd | ||
|
||
; FindJRE (find "javaw.exe") | ||
; 1 - Search in .\jre directory (e.g. JRE Installed with application) | ||
; 2 - Search in JAVA_HOME environment variable | ||
; 3 - Search in the native registry | ||
; 4 - Search in the 32-bit registry | ||
; 5 - Fall-back to "javaw.exe" (such as in current dir or PATH) | ||
Function FindJRE | ||
Push $R0 | ||
Push $R1 | ||
|
||
ClearErrors | ||
StrCpy $R0 "$EXEDIR\jre\bin\javaw.exe" | ||
IfFileExists $R0 JreFound | ||
StrCpy $R0 "" | ||
|
||
ClearErrors | ||
ReadEnvStr $R0 "JAVA_HOME" | ||
StrCpy $R0 "$R0\bin\javaw.exe" | ||
IfErrors 0 JreFound | ||
|
||
ClearErrors | ||
ReadRegStr $R1 HKLM "Software\JavaSoft\Java Runtime Environment" "CurrentVersion" | ||
ReadRegStr $R0 HKLM "Software\JavaSoft\Java Runtime Environment\$R1" "JavaHome" | ||
StrCpy $R0 "$R0\bin\javaw.exe" | ||
|
||
IfErrors 0 JreFound | ||
; Fall-back to 32-bit registry | ||
${If} ${RunningX64} | ||
ReadRegStr $R1 HKLM "Software\Wow6432Node\JavaSoft\Java Runtime Environment" "CurrentVersion" | ||
ReadRegStr $R0 HKLM "Software\Wow6432Node\JavaSoft\Java Runtime Environment\$R1" "JavaHome" | ||
StrCpy $R0 "$R0\bin\javaw.exe" | ||
${EndIf} | ||
|
||
StrCpy $R0 "javaw.exe" | ||
|
||
JreFound: | ||
Pop $R1 | ||
Exch $R0 | ||
FunctionEnd | ||
|
||
Function .onInit | ||
${If} ${RunningX64} | ||
; Force 64-bit registry view by default | ||
SetRegView 64 | ||
; Default to 64-bit Program Files | ||
StrCpy $INSTDIR "$PROGRAMFILES64\${socket.name}" | ||
${EndIf} | ||
FunctionEnd |
4c40812
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#94