Skip to content

Commit 4379c67

Browse files
committed
fix: Clean orphaned uninstall keys on install
The installer (and auto-updater, which runs the same installer with `/S --updated`) now removes the braced uninstall registry key left behind by the electron-builder v21 era installers, plus its brace-less per-machine variant from the v19 era, so a single Twake Desktop entry ever shows up in Windows' installed apps list. The key currently written by the installer (no braces, in `SHELL_CONTEXT`) is never touched.
1 parent 88c71ce commit 4379c67

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

build/installer.nsh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; Custom NSIS macros for Twake Desktop (included via `nsis.include` in
2+
; electron-builder-config.js).
3+
;
4+
; Twake Desktop appId is `io.cozy.desktop`, whose electron-builder NSIS UUID
5+
; v5 is 4e3f3566-be06-5f9a-b012-0cf924cd77aa. The uninstall registry key
6+
; format changed over electron-builder versions:
7+
; - v19 (Twake <= v3.15.x): no braces
8+
; - v21 (Twake v3.16.0-v3.30.x): {with braces}
9+
; - v22+ (Twake >= v3.31): no braces (current)
10+
11+
!include "nsDialogs.nsh"
12+
!include "FileFunc.nsh"
13+
14+
!define APP_UNINSTALL_KEY_NO_BRACES "Software\Microsoft\Windows\CurrentVersion\Uninstall\4e3f3566-be06-5f9a-b012-0cf924cd77aa"
15+
!define APP_UNINSTALL_KEY_BRACES "Software\Microsoft\Windows\CurrentVersion\Uninstall\{4e3f3566-be06-5f9a-b012-0cf924cd77aa}"
16+
17+
; Runs at the very end of the install section, on fresh installs, manual
18+
; upgrades and auto-updates (the auto-updater runs the same installer with
19+
; `/S --updated`; `customInstall` has no silent-mode guard in the
20+
; electron-builder templates).
21+
!macro customInstall
22+
; Remove orphaned uninstall keys left behind by past installers so that a
23+
; single entry ever shows up in Windows' installed apps list. The key
24+
; currently written by the installer (no braces, in SHELL_CONTEXT) is never
25+
; touched here.
26+
DeleteRegKey HKCU "${APP_UNINSTALL_KEY_BRACES}"
27+
${if} $installMode == "all"
28+
DeleteRegKey HKLM "${APP_UNINSTALL_KEY_BRACES}"
29+
; Per-machine installs from the electron-builder v19 era
30+
DeleteRegKey HKLM "${APP_UNINSTALL_KEY_NO_BRACES}"
31+
${endif}
32+
!macroend
33+
34+
; Runs at the very end of the uninstall section, after the uninstall
35+
; registry keys have been removed and right before `quitSuccess` (which only
36+
; calls Quit). The one-click uninstaller has no MUI pages: un.onInit forces
37+
; `SetSilent silent` after its confirmation MessageBox, so we briefly restore
38+
; the normal mode to show our own nsDialogs dialog.
39+
!macro customUnInstall
40+
; Placeholder; filled in the next commit.
41+
!macroend

electron-builder-config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ const config = {
7171
]
7272
},
7373

74+
nsis: {
75+
include: 'build/installer.nsh'
76+
},
77+
7478
win: {
7579
target: [{ target: 'nsis', arch: ['x64'] }],
7680
artifactName: 'Twake-Desktop-Setup.${ext}',

0 commit comments

Comments
 (0)