Skip to content

Commit 6e36ebb

Browse files
authored
fix(nsis): set correct ShellVarContext for uninstaller, closes #7315 (#7342)
1 parent 32218a6 commit 6e36ebb

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
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 uninstaller failing to remove Start Menu shortcut if `perMachine` mode is used.

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,7 @@ FunctionEnd
344344
!include "{{this}}"
345345
{{/each}}
346346

347-
Var PassiveMode
348-
Function .onInit
349-
${GetOptions} $CMDLINE "/P" $PassiveMode
350-
IfErrors +2 0
351-
StrCpy $PassiveMode 1
352-
353-
!if "${DISPLAYLANGUAGESELECTOR}" == "true"
354-
!insertmacro MUI_LANGDLL_DISPLAY
355-
!endif
356-
347+
!macro SetContext
357348
!if "${INSTALLMODE}" == "currentUser"
358349
SetShellVarContext current
359350
!else if "${INSTALLMODE}" == "perMachine"
@@ -369,6 +360,19 @@ Function .onInit
369360
SetRegView 32
370361
!endif
371362
${EndIf}
363+
!macroend
364+
365+
Var PassiveMode
366+
Function .onInit
367+
${GetOptions} $CMDLINE "/P" $PassiveMode
368+
IfErrors +2 0
369+
StrCpy $PassiveMode 1
370+
371+
!if "${DISPLAYLANGUAGESELECTOR}" == "true"
372+
!insertmacro MUI_LANGDLL_DISPLAY
373+
!endif
374+
375+
!insertmacro SetContext
372376

373377
${If} $INSTDIR == ""
374378
; Set default install location
@@ -595,15 +599,7 @@ Function .onInstSuccess
595599
FunctionEnd
596600

597601
Function un.onInit
598-
${If} ${RunningX64}
599-
!if "${ARCH}" == "x64"
600-
SetRegView 64
601-
!else if "${ARCH}" == "arm64"
602-
SetRegView 64
603-
!else
604-
SetRegView 32
605-
!endif
606-
${EndIf}
602+
!insertmacro SetContext
607603

608604
!if "${INSTALLMODE}" == "both"
609605
!insertmacro MULTIUSER_UNINIT

0 commit comments

Comments
 (0)