Skip to content

Commit

Permalink
fix(installer): avoid files are deleted on system reboot after reinst…
Browse files Browse the repository at this point in the history
…allation (#1520)

* fix(installer): avoid files are deleted on system reboot when weasel is reinstalled in the same WeaselRoot

* fix(installer): remove old version files with installer, not uninstaller.exe
  • Loading branch information
fxliang authored Mar 3, 2025
1 parent 41dc044 commit 2f92c6c
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions output/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,34 @@ uninst:
CopyFiles $R1\data\*.* $TEMP\weasel-backup

call_uninstaller:
ExecWait '$R0 /S'
ExecWait '"$R1\WeaselServer.exe" /quit'
ExecWait '"$R1\WeaselSetup.exe" /u'
; Remove registry keys
DeleteRegKey HKLM SOFTWARE\Rime
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Weasel"
; don't redirect on 64 bit system for auto run setting
${If} ${IsNativeARM64}
SetRegView 64
${ElseIf} ${IsNativeAMD64}
SetRegView 64
${Endif}
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "WeaselServer"
; recover back to 32bit view
SetRegView 32
; Remove files and uninstaller
Delete "$R1\data\opencc\*.*"
Delete "$R1\data\preview\*.*"
Delete "$R1\data\*.*"
Delete "$R1\*.*"
RMDir "$R1\data\opencc"
RMDir "$R1\data\preview"
RMDir "$R1\data"
RMDir "$R1"
SetShellVarContext all
Delete "$SMPROGRAMS\$(DISPLAYNAME)\*.*"
RMDir "$SMPROGRAMS\$(DISPLAYNAME)"
; Prompt reboot
SetRebootFlag true
Sleep 800

done:
Expand Down Expand Up @@ -378,17 +405,17 @@ Section "Uninstall"

; Remove files and uninstaller
SetOutPath $TEMP
Delete /REBOOTOK "$INSTDIR\data\opencc\*.*"
Delete /REBOOTOK "$INSTDIR\data\preview\*.*"
Delete /REBOOTOK "$INSTDIR\data\*.*"
Delete /REBOOTOK "$INSTDIR\*.*"
RMDir /REBOOTOK "$INSTDIR\data\opencc"
RMDir /REBOOTOK "$INSTDIR\data\preview"
RMDir /REBOOTOK "$INSTDIR\data"
RMDir /REBOOTOK "$INSTDIR"
Delete "$INSTDIR\data\opencc\*.*"
Delete "$INSTDIR\data\preview\*.*"
Delete "$INSTDIR\data\*.*"
Delete "$INSTDIR\*.*"
RMDir "$INSTDIR\data\opencc"
RMDir "$INSTDIR\data\preview"
RMDir "$INSTDIR\data"
RMDir "$INSTDIR"
SetShellVarContext all
Delete /REBOOTOK "$SMPROGRAMS\$(DISPLAYNAME)\*.*"
RMDir /REBOOTOK "$SMPROGRAMS\$(DISPLAYNAME)"
Delete "$SMPROGRAMS\$(DISPLAYNAME)\*.*"
RMDir "$SMPROGRAMS\$(DISPLAYNAME)"

; Prompt reboot
SetRebootFlag true
Expand Down

0 comments on commit 2f92c6c

Please sign in to comment.