Skip to content

Commit 431922e

Browse files
committed
fix(nsis): get InstallLocation from UninstallerString if not found #735
1 parent cca23b4 commit 431922e

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

src/build-cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (process.env.CI == null && process.env.NO_UPDATE_NOTIFIER == null) {
1616
const notifier = updateNotifier({pkg: it})
1717
if (notifier.update != null) {
1818
notifier.notify({
19-
message: `Update available ${dim(notifier.update.current)}${reset(" → ")}${green(notifier.update.latest)} \nRun ${cyan("npm i electron-builder")} to update`
19+
message: `Update available ${dim(notifier.update.current)}${reset(" → ")}${green(notifier.update.latest)} \nRun ${cyan("npm i electron-builder --save-dev")} to update`
2020
})
2121
}
2222
})

templates/nsis/common.nsh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,29 @@ Function GetInQuotes
7171
Pop $R1
7272
Exch $R0
7373
FunctionEnd
74+
75+
Function GetFileParent
76+
Exch $R0
77+
Push $R1
78+
Push $R2
79+
Push $R3
80+
81+
StrCpy $R1 0
82+
StrLen $R2 $R0
83+
84+
loop:
85+
IntOp $R1 $R1 + 1
86+
IntCmp $R1 $R2 get 0 get
87+
StrCpy $R3 $R0 1 -$R1
88+
StrCmp $R3 "\" get
89+
Goto loop
90+
91+
get:
92+
StrCpy $R0 $R0 -$R1
93+
94+
Pop $R3
95+
Pop $R2
96+
Pop $R1
97+
Exch $R0
98+
FunctionEnd
7499
!endif

templates/nsis/installSection.nsh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@
77
Pop $R0
88

99
ReadRegStr $R1 ${ROOT_KEY} "${INSTALL_REGISTRY_KEY}" InstallLocation
10+
${if} $R1 == ""
11+
${andIf} $R0 != ""
12+
# https://github.com/electron-userland/electron-builder/issues/735#issuecomment-246918567
13+
Push $R0
14+
Call GetFileParent
15+
Pop $R1
16+
${endif}
17+
1018
${if} $R1 != ""
11-
${AndIf} $R0 != ""
19+
${andIf} $R0 != ""
1220
CopyFiles /SILENT /FILESONLY "$R0" "$PLUGINSDIR\old-uninstaller.exe"
1321

1422
${if} $installMode == "CurrentUser"
15-
${OrIf} ${ROOT_KEY} == "HKEY_CURRENT_USER"
23+
${orIf} ${ROOT_KEY} == "HKEY_CURRENT_USER"
1624
StrCpy $0 "/currentuser"
1725
${else}
1826
StrCpy $0 "/allusers"
1927
${endif}
20-
# MessageBox MB_OK|MB_ICONEXCLAMATION '"$PLUGINSDIR\old-uninstaller.exe" "_?=$R1" /S /KEEP_APP_DATA $0'
2128
ExecWait '"$PLUGINSDIR\old-uninstaller.exe" "_?=$R1" /S /KEEP_APP_DATA $0'
2229
${endif}
2330
${endif}

0 commit comments

Comments
 (0)