mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-01 12:01:05 +00:00
Two faults in the uninstall hook, found by running it for the first time: - NSIS has no doubled-quote escape, so the '' written for PowerShell's single quotes ended the NSIS string at the first one. The plugin got a truncated command PowerShell could not parse, and the hook silently did nothing: uninstalling the desktop app left the tray, its Run value and its marker behind. Each inner quote is now the NSIS escape. - An upgrade runs the previous version's uninstaller first, with the updated flag, and the hook removed the tray there too, so every desktop upgrade uninstalled the tray and reinstalled it with an elevation prompt. The hook now leaves the tray alone during an upgrade.
33 lines
2.5 KiB
NSIS
33 lines
2.5 KiB
NSIS
; Uninstalling CodeBurn Desktop removes the tray app only when this app is what
|
|
; put it there. src/menubar-installer.ts writes the marker at install time and
|
|
; credits whoever got there first, so a tray app someone installed by hand with
|
|
; `codeburn menubar` survives, and the one the desktop app installed goes with it.
|
|
;
|
|
; PowerShell does the reading: the marker is JSON, and the product code lives
|
|
; inside the uninstall string Windows Installer wrote. `$$` is a literal dollar
|
|
; for NSIS, so every `$$` below is a PowerShell variable, and every string inside
|
|
; the command is single-quoted. NSIS has no doubled-quote escape: a `''` inside a
|
|
; single-quoted NSIS string ends it, and the plugin then received a truncated
|
|
; command that PowerShell could not parse, so the hook silently did nothing. Each
|
|
; inner quote is therefore written as `$\'`, the NSIS escape for a literal quote.
|
|
|
|
!macro customUnInstall
|
|
; An upgrade runs the previous version's uninstaller first, with --updated, and
|
|
; the tray app must survive that: the new desktop app reuses it, and removing it
|
|
; here would cost every upgrade a tray reinstall and its elevation prompt.
|
|
${if} ${isUpdated}
|
|
DetailPrint "Upgrade in progress; the tray app stays."
|
|
${else}
|
|
DetailPrint "Checking whether CodeBurn installed the tray app..."
|
|
nsExec::ExecToLog '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "$$marker = Join-Path $$env:LOCALAPPDATA (Join-Path $\'codeburn-menubar$\' $\'installed-by.json$\'); if (Test-Path $$marker) { $$record = Get-Content -Raw $$marker | ConvertFrom-Json; if ($$record.installedBy -eq $\'desktop$\') { Get-Process -Name $\'codeburn-menubar$\' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue; if ($$record.uninstallString -match $\'\{[0-9A-Fa-f-]{36}\}$\') { Start-Process -Wait -FilePath $\'msiexec.exe$\' -ArgumentList $\'/x$\', $$Matches[0], $\'/passive$\', $\'/norestart$\' }; Remove-Item -Force -ErrorAction SilentlyContinue $$marker } }"'
|
|
Pop $0
|
|
|
|
; The launcher this app writes so the tray app has a CLI to run at all
|
|
; (app/electron/menubar.ts). It names this app's own executable, which is about
|
|
; to be gone, and unlike the tray app itself there is no copy of it anybody
|
|
; else could have put there, so it goes unconditionally. The directory follows
|
|
; only if the tray app left nothing else in it.
|
|
Delete "$LOCALAPPDATA\codeburn-menubar\codeburn-cli.cmd"
|
|
RMDir "$LOCALAPPDATA\codeburn-menubar"
|
|
${endif}
|
|
!macroend
|