Skip to content

Commit 32218a6

Browse files
authored
fix(bundler/nsis): use uninstallstring to find wix installation (#7326)
* add change file Signed-off-by: luofei <luoffei@outlook.com> * fix(bundler/nsis): Check if the previous installation was done using WiX Signed-off-by: luofei <luoffei@outlook.com> * Update .changes/fix-nsis-previous-installation-method.md --------- Signed-off-by: luofei <luoffei@outlook.com>
1 parent 0ae53f4 commit 32218a6

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-bundler': 'patch:bug'
3+
---
4+
5+
On Windows, fix NSIS installer identifying a previous NSIS-installed app as WiX-installed app and then fails to uninstall it.

tooling/bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
Unicode true
2+
SetCompressor /SOLID lzma
3+
14
!include MUI2.nsh
25
!include FileFunc.nsh
36
!include x64.nsh
47
!include WordFunc.nsh
8+
!include "StrFunc.nsh"
9+
${StrCase}
10+
${StrLoc}
511

612
!define MANUFACTURER "{{manufacturer}}"
713
!define PRODUCTNAME "{{product_name}}"
@@ -31,8 +37,6 @@
3137
Name "${PRODUCTNAME}"
3238
BrandingText "{{copyright}}"
3339
OutFile "${OUTFILE}"
34-
Unicode true
35-
SetCompressor /SOLID lzma
3640

3741
VIProductVersion "${VERSIONWITHBUILD}"
3842
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
@@ -135,7 +139,11 @@ Function PageReinstall
135139
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "DisplayName"
136140
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "Publisher"
137141
StrCmp "$R0$R1" "${PRODUCTNAME}${MANUFACTURER}" 0 wix_loop
138-
StrCpy $R5 "wix"
142+
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "UninstallString"
143+
${StrCase} $R1 $R0 "L"
144+
${StrLoc} $R0 $R1 "msiexec" ">"
145+
StrCmp $R0 0 0 wix_done
146+
StrCpy $R7 "wix"
139147
StrCpy $R6 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1"
140148
Goto compare_version
141149
wix_done:
@@ -149,7 +157,7 @@ Function PageReinstall
149157
; and modify the messages presented to the user accordingly
150158
compare_version:
151159
StrCpy $R4 "$(older)"
152-
${If} $R5 == "wix"
160+
${If} $R7 == "wix"
153161
ReadRegStr $R0 HKLM "$R6" "DisplayVersion"
154162
${Else}
155163
ReadRegStr $R0 SHCTX "${UNINSTKEY}" "DisplayVersion"
@@ -244,7 +252,7 @@ Function PageLeaveReinstall
244252
HideWindow
245253
ClearErrors
246254

247-
${If} $R5 == "wix"
255+
${If} $R7 == "wix"
248256
ReadRegStr $R1 HKLM "$R6" "UninstallString"
249257
ExecWait '$R1' $0
250258
${Else}

0 commit comments

Comments
 (0)