Skip to content

Commit ab8dcbe

Browse files
committed
fix(updater): bring the app back when a silent Windows update's UAC is declined
A silent update of a per-machine NSIS install elevates in the install section, after the app has quit. Declining UAC (1223) made the stock installer just quit, leaving OpenScreen closed. Elevate in customInit instead and relaunch the installed app if elevation fails. Refs #1461
1 parent 8ecc76b commit ab8dcbe

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎build/installer.nsh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; Picked up by electron-builder as `<buildResources>/installer.nsh` (the NSIS `include` option).
2+
3+
; A silent update of a per-machine install (`/S`, see installsSilently in electron/auto-updater.ts)
4+
; asks for UAC in the install section, by which time the app has already quit. Declining it
5+
; (error 1223) makes electron-builder's installer.nsi just Quit, so OpenScreen stays closed (#1461).
6+
; Elevate here instead, as the stock section would, and bring the app back if that fails. The
7+
; downloaded update stays cached, so the user can retry it.
8+
!macro customInit
9+
${if} ${Silent}
10+
${andIf} $hasPerMachineInstallation == "1"
11+
${andIfNot} ${UAC_IsAdmin}
12+
!insertmacro UAC_RunElevated
13+
${if} $0 != 0
14+
${andIf} ${isForceRun}
15+
ExecShell "open" "$perMachineInstallationFolder\${APP_EXECUTABLE_FILENAME}"
16+
${endIf}
17+
Quit
18+
${endIf}
19+
!macroend

0 commit comments

Comments
 (0)