Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Changes from all 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
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