Skip to content

Commit

Permalink
NSIS: make the installer wait for the uninstall to finish before proc…
Browse files Browse the repository at this point in the history
…eeding; fix #2546 (#2619)
  • Loading branch information
ctrlaltca authored Mar 17, 2024
1 parent edd0470 commit c0a8998
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion cmake/KVIrc.nsi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,48 @@ LangString WinVerUnsupported ${LANG_ENGLISH} "KVIrc does not support the current

!include ".\translations\*.nsi"

Function TrimQuotes
Exch $R0
Push $R1

StrCpy $R1 $R0 1
StrCmp $R1 `"` 0 +2
StrCpy $R0 $R0 `` 1
StrCpy $R1 $R0 1 -1
StrCmp $R1 `"` 0 +2
StrCpy $R0 $R0 -1

Pop $R1
Exch $R0
FunctionEnd

Function GetParent

Exch $R0
Push $R1
Push $R2
Push $R3

StrCpy $R1 0
StrLen $R2 $R0

loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop
get:
StrCpy $R0 $R0 -$R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
;--------------------------------
; Sections
Expand Down Expand Up @@ -193,7 +235,16 @@ check64:
;Run the uninstaller
uninst:
ClearErrors
ExecWait "$R0"
; R0 contains the quoted full path to uninstall.exe
Push $R0
Call TrimQuotes
Call GetParent
Pop $R0
; at this point $R0 will equal to "C:\Program Files\KVirc"
InitPluginsDir
CreateDirectory "$pluginsdir\unold"
CopyFiles /SILENT /FILESONLY "$R0\uninstall.exe" "$pluginsdir\unold"
ExecWait '"$pluginsdir\unold\uninstall.exe" _?=$R0'
done:
Expand Down

0 comments on commit c0a8998

Please sign in to comment.