Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions nsis/tesseract.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,27 @@ SectionGroup "Additional language data (download)" SecGrp_ALD

SectionGroupEnd

Section /o "Add to PATH environment variable" SecAddEnvPath
; Check if the installer is running in "Current User" mode
StrCmp $MultiUser.InstallMode "CurrentUser" SetUserPath 0

; If "All Users" mode, verify that the current process is actually elevated
UserInfo::GetAccountType
Pop $0
StrCmp $0 "Admin" SetSystemPath SetUserPath

SetSystemPath:
EnVar::SetHKLM
Goto UpdatePath

SetUserPath:
EnVar::SetHKCU

UpdatePath:
EnVar::AddValue "Path" "$INSTDIR"
Pop $0 ; Clean up the stack (returns 0 on success)
Comment thread
eduardomozart marked this conversation as resolved.
Outdated
Comment thread
stweil marked this conversation as resolved.
Outdated
SectionEnd

;--------------------------------
;Descriptions
; At first we need to localize installer for languages which supports well in tesseract: Eng, Spa, Ger, Ita, Dutch + Russian (it is authors native language)
Expand Down Expand Up @@ -1164,6 +1185,7 @@ SectionGroupEnd
!insertmacro MUI_DESCRIPTION_TEXT ${SecGrp_LD} $(DESC_SecGrp_LD)
!insertmacro MUI_DESCRIPTION_TEXT ${SecGrp_ASD} $(DESC_SecGrp_ASD)
!insertmacro MUI_DESCRIPTION_TEXT ${SecGrp_ALD} $(DESC_SecGrp_ALD)
!insertmacro MUI_DESCRIPTION_TEXT ${SecAddEnvPath} $(DESC_SecAddEnvPath)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
Expand Down Expand Up @@ -1196,6 +1218,24 @@ Section -un.Main UNSEC0000
RMDir "$INSTDIR\doc"
RMDir /r "$INSTDIR\tessdata"
RMDir "$INSTDIR"

# remove from PATH
StrCmp $MultiUser.InstallMode "CurrentUser" UnSetUserPath 0

UserInfo::GetAccountType
Pop $0
StrCmp $0 "Admin" UnSetSystemPath UnSetUserPath

UnSetSystemPath:
EnVar::SetHKLM
Goto RemovePath

UnSetUserPath:
EnVar::SetHKCU

RemovePath:
EnVar::DeleteValue "Path" "$INSTDIR"
Pop $0
Comment thread
eduardomozart marked this conversation as resolved.
Outdated
Comment thread
stweil marked this conversation as resolved.
SectionEnd

Function PageReinstall
Expand Down Expand Up @@ -1433,6 +1473,17 @@ Function .onInit
Vietnamese: !insertmacro SelectSection ${SecLang_vie}

lang_end:

; --- Command Line Parsing ---
${GetParameters} $R0

; Check for "Add to PATH environment variable" flag (case-insensitive)
ClearErrors
${GetOptions} $R0 "/ADDENVPATH" $R1
Comment thread
eduardomozart marked this conversation as resolved.
${IfNot} ${Errors}
!insertmacro SelectSection ${SecAddEnvPath}
${EndIf}
; ----------------------------
FunctionEnd

Function un.onInit
Expand Down