fix(installer): add on-demand UAC elevation check for protected target directories
This commit is contained in:
1 file changed
+31
@@ -23,6 +23,7 @@ SetOverwrite on
|
|||||||
|
|
||||||
!insertmacro MUI_PAGE_WELCOME
|
!insertmacro MUI_PAGE_WELCOME
|
||||||
!insertmacro MUI_PAGE_COMPONENTS
|
!insertmacro MUI_PAGE_COMPONENTS
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE DirectoryLeave
|
||||||
!insertmacro MUI_PAGE_DIRECTORY
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
!insertmacro MUI_PAGE_INSTFILES
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
!define MUI_FINISHPAGE_RUN "$INSTDIR\${EXE_NAME}"
|
!define MUI_FINISHPAGE_RUN "$INSTDIR\${EXE_NAME}"
|
||||||
@@ -107,6 +108,36 @@ LangString DESC_DESKTOP ${LANG_ENGLISH} "Create a shortcut on the Desktop."
|
|||||||
LangString DESC_DESKTOP ${LANG_RUSSIAN} "Создать ярлык на Рабочем столе."
|
LangString DESC_DESKTOP ${LANG_RUSSIAN} "Создать ярлык на Рабочем столе."
|
||||||
LangString MSG_RUNNING ${LANG_ENGLISH} "${APP_NAME} is currently running.$\r$\n$\r$\nClick OK to close it and proceed with the update, or Cancel to abort."
|
LangString MSG_RUNNING ${LANG_ENGLISH} "${APP_NAME} is currently running.$\r$\n$\r$\nClick OK to close it and proceed with the update, or Cancel to abort."
|
||||||
LangString MSG_RUNNING ${LANG_RUSSIAN} "Приложение ${APP_NAME} сейчас запущено.$\r$\n$\r$\nНажмите ОК, чтобы закрыть его и продолжить обновление, или Отмена для выхода."
|
LangString MSG_RUNNING ${LANG_RUSSIAN} "Приложение ${APP_NAME} сейчас запущено.$\r$\n$\r$\nНажмите ОК, чтобы закрыть его и продолжить обновление, или Отмена для выхода."
|
||||||
|
LangString MSG_ADMIN_REQ ${LANG_ENGLISH} "Administrator privileges are required to install into:$\r$\n$INSTDIR$\r$\n$\r$\nRestart installer with administrator privileges?"
|
||||||
|
LangString MSG_ADMIN_REQ ${LANG_RUSSIAN} "Для установки в выбранную папку требуются права администратора:$\r$\n$INSTDIR$\r$\n$\r$\nПерезапустить установку от имени администратора?"
|
||||||
|
|
||||||
|
Function DirectoryLeave
|
||||||
|
ClearErrors
|
||||||
|
UserInfo::GetAccountType
|
||||||
|
Pop $0
|
||||||
|
StrCmp $0 "Admin" can_write 0
|
||||||
|
|
||||||
|
CreateDirectory "$INSTDIR"
|
||||||
|
FileOpen $0 "$INSTDIR\.write_test" w
|
||||||
|
IfErrors need_admin
|
||||||
|
|
||||||
|
FileClose $0
|
||||||
|
Delete "$INSTDIR\.write_test"
|
||||||
|
Goto can_write
|
||||||
|
|
||||||
|
need_admin:
|
||||||
|
ClearErrors
|
||||||
|
MessageBox MB_YESNO|MB_ICONQUESTION $(MSG_ADMIN_REQ) IDYES do_elevate IDNO stay_here
|
||||||
|
|
||||||
|
do_elevate:
|
||||||
|
ExecShell "runas" "$EXEPATH" '/D=$INSTDIR'
|
||||||
|
Quit
|
||||||
|
|
||||||
|
stay_here:
|
||||||
|
Abort
|
||||||
|
|
||||||
|
can_write:
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
Function .onInit
|
Function .onInit
|
||||||
check_running:
|
check_running:
|
||||||
|
|||||||
Reference in new issue
Block a user