Skip to content

Commit 9c5f8ed

Browse files
committed
request admin rights for windows installer - fixes Win 7 install
1 parent 9e707cb commit 9c5f8ed

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packaging/windows/pcbasic.nsi

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,29 @@
2020
;--------------------------------
2121
;General
2222

23+
2324
;Name and file
2425
Name "PC-BASIC 3.23"
2526
OutFile "pcbasic-win32.exe"
2627

28+
29+
30+
31+
32+
2733
;Default installation folder
2834
InstallDir "$programfiles\PC-BASIC"
2935
;Get installation folder from registry if available
3036
InstallDirRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir"
3137

3238
;Request application privileges for Windows Vista
33-
RequestExecutionLevel user
39+
;RequestExecutionLevel user
40+
41+
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
42+
43+
!include LogicLib.nsh
44+
45+
3446

3547
;Start Menu Folder Page Configuration
3648
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
@@ -115,6 +127,15 @@ SectionEnd
115127

116128
Function .onInit
117129
;prepare log always within .onInit function
130+
131+
UserInfo::GetAccountType
132+
pop $0
133+
${If} $0 != "admin" ;Require admin rights on NT4+
134+
MessageBox mb_iconstop "Administrator rights required!"
135+
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
136+
Quit
137+
${EndIf}
138+
118139
!insertmacro UNINSTALL.LOG_PREPARE_INSTALL
119140
FunctionEnd
120141

0 commit comments

Comments
 (0)