Skip to main content

The easiest way would be to use a wrapper to launch your JVM, then elevate the wrapper. I use a simple NSIS installer script with the UAC plugin to do this:

; Java Launcher ;--------------

;You want to change the below lines

Name "my program"

Caption "my program Launcher"

Icon "iconfile.ico"

OutFile "java launcher.exe"

; param below can be user, admin

RequestExecutionLevel admin

!include UAC.nsh

SilentInstall silent AutoCloseWindow true ShowInstDetails show

Section ""

;command to execute

StrCpy $0 'javaw -jar myjarfile'

SetOutPath $EXEDIR

Exec $0

SectionEnd

; Java Launcher ;-------------- ; You want to change the below lines Name "my program" Caption "my program Launcher" Icon "iconfile.ico" OutFile "java launcher.exe" ; param below can be user, admin RequestExecutionLevel admin !include UAC.nsh SilentInstall silent AutoCloseWindow true ShowInstDetails show Section "" ; command to execute StrCpy $0 'javaw -jar myjarfile' SetOutPath $EXEDIR Exec $0 SectionEnd 

The easiest way would be to use a wrapper to launch your JVM, then elevate the wrapper. I use a simple NSIS installer script with the UAC plugin to do this:

; Java Launcher ;--------------

;You want to change the below lines

Name "my program"

Caption "my program Launcher"

Icon "iconfile.ico"

OutFile "java launcher.exe"

; param below can be user, admin

RequestExecutionLevel admin

!include UAC.nsh

SilentInstall silent AutoCloseWindow true ShowInstDetails show

Section ""

;command to execute

StrCpy $0 'javaw -jar myjarfile'

SetOutPath $EXEDIR

Exec $0

SectionEnd

The easiest way would be to use a wrapper to launch your JVM, then elevate the wrapper. I use a simple NSIS installer script with the UAC plugin to do this:

; Java Launcher ;-------------- ; You want to change the below lines Name "my program" Caption "my program Launcher" Icon "iconfile.ico" OutFile "java launcher.exe" ; param below can be user, admin RequestExecutionLevel admin !include UAC.nsh SilentInstall silent AutoCloseWindow true ShowInstDetails show Section "" ; command to execute StrCpy $0 'javaw -jar myjarfile' SetOutPath $EXEDIR Exec $0 SectionEnd 
Source Link

The easiest way would be to use a wrapper to launch your JVM, then elevate the wrapper. I use a simple NSIS installer script with the UAC plugin to do this:

; Java Launcher ;--------------

;You want to change the below lines

Name "my program"

Caption "my program Launcher"

Icon "iconfile.ico"

OutFile "java launcher.exe"

; param below can be user, admin

RequestExecutionLevel admin

!include UAC.nsh

SilentInstall silent AutoCloseWindow true ShowInstDetails show

Section ""

;command to execute

StrCpy $0 'javaw -jar myjarfile'

SetOutPath $EXEDIR

Exec $0

SectionEnd