Try something else.

Took 2 minutes
This commit is contained in:
Lukas Brübach 2026-06-12 11:34:23 +02:00
parent b8a2a41f6e
commit 8291438b3a

View file

@ -89,19 +89,7 @@ ${IfNot} ${Errors}
Quit Quit
${EndIf} ${EndIf}
ClearErrors ; Detect reinstall mode first
${GetOptions} $9 "/PORTABLE" $8
${IfNot} ${Errors}
StrCpy $PortableMode 1
StrCpy $0 $PortableDestDir
${Else}
StrCpy $PortableMode 0
StrCpy $0 $NormalDestDir
${If} ${Silent}
Call RequireAdmin
${EndIf}
${EndIf}
ClearErrors ClearErrors
${GetOptions} $9 "/R" $8 ${GetOptions} $9 "/R" $8
${IfNot} ${Errors} ${IfNot} ${Errors}
@ -112,14 +100,31 @@ ${Else}
StrCpy $ReinstallMode 0 StrCpy $ReinstallMode 0
${EndIf} ${EndIf}
${If} $InstDir == "" ; Only parse /PORTABLE for fresh installs
; User did not use /D to specify a directory, ${If} $ReinstallMode = 0
; we need to set a default based on the install mode ClearErrors
StrCpy $InstDir $0 ${GetOptions} $9 "/PORTABLE" $8
${IfNot} ${Errors}
StrCpy $PortableMode 1
StrCpy $0 $PortableDestDir
${Else}
StrCpy $PortableMode 0
StrCpy $0 $NormalDestDir
${If} ${Silent}
Call RequireAdmin
${EndIf}
${EndIf}
${EndIf} ${EndIf}
Call SetModeDestinationFromInstdir
; --- Detect portable install when using /R --- ${If} $InstDir == ""
${If} $ReinstallMode = 1
StrCpy $InstDir $NormalDestDir
${Else}
StrCpy $InstDir $0
${EndIf}
${EndIf}
; Detect portable installs during update from portable.dat
${If} $ReinstallMode = 1 ${If} $ReinstallMode = 1
IfFileExists "$InstDir\portable.dat" 0 not_portable IfFileExists "$InstDir\portable.dat" 0 not_portable
StrCpy $PortableMode 1 StrCpy $PortableMode 1
@ -131,7 +136,11 @@ ${If} $ReinstallMode = 1
portable_done: portable_done:
${EndIf} ${EndIf}
Call SetModeDestinationFromInstdir
; Only uninstall registered installs
${If} $ReinstallMode = 1 ${If} $ReinstallMode = 1
${AndIf} $PortableMode = 0
Call AutoUninstallIfNeeded Call AutoUninstallIfNeeded
${EndIf} ${EndIf}
@ -157,10 +166,10 @@ FunctionEnd
Function SetModeDestinationFromInstdir Function SetModeDestinationFromInstdir
${If} $PortableMode = 0 ${If} $PortableMode = 1
StrCpy $NormalDestDir $InstDir
${Else}
StrCpy $PortableDestDir $InstDir StrCpy $PortableDestDir $InstDir
${Else}
StrCpy $NormalDestDir $InstDir
${EndIf} ${EndIf}
FunctionEnd FunctionEnd