Skip to content

Commit

Permalink
enhance(nsis): clean up reg keys in uninstaller (#12427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master authored Jan 20, 2025
1 parent 90c6546 commit b8eb288
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/nsis-cleanup-installdir-reg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch:bug'
---

Clean up `Software\${MANUFACTURER}\${PRODUCTNAME}` registry key in the NSIS uninstaller if "Delete application data" option is checked when uninstalling.
14 changes: 11 additions & 3 deletions crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ ${StrLoc}
!define WEBVIEW2INSTALLERPATH "{{webview2_installer_path}}"
!define MINIMUMWEBVIEW2VERSION "{{minimum_webview2_version}}"
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}"
!define MANUPRODUCTKEY "Software\${MANUFACTURER}\${PRODUCTNAME}"
!define MANUKEY "Software\${MANUFACTURER}"
!define MANUPRODUCTKEY "${MANUKEY}\${PRODUCTNAME}"
!define UNINSTALLERSIGNCOMMAND "{{uninstaller_sign_cmd}}"
!define ESTIMATEDSIZE "{{estimated_size}}"
!define STARTMENUFOLDER "{{start_menu_folder}}"
Expand Down Expand Up @@ -834,12 +835,19 @@ Section Uninstall
DeleteRegKey HKCU "${UNINSTKEY}"
!endif

DeleteRegValue HKCU "${MANUPRODUCTKEY}" "Installer Language"

; Delete app data if the checkbox is selected
; and if not updating
${If} $DeleteAppDataCheckboxState = 1
${AndIf} $UpdateMode <> 1
; Clear the install location $INSTDIR from registry
DeleteRegKey SHCTX "${MANUPRODUCTKEY}"
DeleteRegKey /ifempty SHCTX "${MANUKEY}"

; Clear the install language from registry
DeleteRegValue HKCU "${MANUPRODUCTKEY}" "Installer Language"
DeleteRegKey /ifempty HKCU "${MANUPRODUCTKEY}"
DeleteRegKey /ifempty HKCU "${MANUKEY}"

SetShellVarContext current
RmDir /r "$APPDATA\${BUNDLEID}"
RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
Expand Down

0 comments on commit b8eb288

Please sign in to comment.