반응형
# https://nsis.sourceforge.io/UAC_plug-in
!macro _UAC_Elevation un
Function ${un}_UAC_Elevation
Push $R0
Exch
Pop $R0
uac_tryagain:
!insertmacro UAC_RunElevated
${Switch} $0
${Case} 0
${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "This $R0 requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
${EndIf}
;fall-through and die
${Case} 1223
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This $R0 requires admin privileges, aborting!"
Quit
${Case} 1062
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
Quit
${Default}
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, error $0"
Quit
${EndSwitch}
SetShellVarContext all
Pop $R0
FunctionEnd
!macroend
!insertmacro _UAC_Elevation ""
!insertmacro _UAC_Elevation "un."
!macro UAC_Elevation
!ifndef __UNINSTALL__
Push "installer"
Call _UAC_Elevation
!else
Push "uninstaller"
Call un._UAC_Elevation
!endif
!macroend
!define UAC_Elevation "!insertmacro UAC_Elevation"
반응형
'NSIS > Reference' 카테고리의 다른 글
[NSIS] 사설 인증서 등록 (2) | 2024.12.25 |
---|---|
[NSIS] 인증서 설치 (0) | 2024.12.25 |
[NSIS] 특수 경로 얻어오기 (0) | 2024.12.25 |
[NSIS] 재배포 패키지 설치 여부 체크 후 설치하는 방법 (0) | 2024.12.11 |
[NSIS] 32비트와 64비트 모듈 등록하는 법. (regsvr32) (0) | 2024.12.11 |