From ca977f4b87c66808b4eac31a6d1925842b4c1570 Mon Sep 17 00:00:00 2001 From: Jet Li Date: Tue, 15 Aug 2023 23:59:44 +0800 Subject: [PATCH] fix(bundler/nsis): revert shell context change before deleting appdata, closes #7588 (#7591) * fix(bundler/nsis): delete app data of current user when uninstall, closes #7588 * fix(bundler/nsis): delete app data of current user when uninstall, closes #7588 * Update .changes/fix-nsis-uninstall-delete-app-data.md --------- --- .changes/fix-nsis-uninstall-delete-app-data.md | 5 +++++ .../src/bundle/windows/templates/installer.nsi | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .changes/fix-nsis-uninstall-delete-app-data.md diff --git a/.changes/fix-nsis-uninstall-delete-app-data.md b/.changes/fix-nsis-uninstall-delete-app-data.md new file mode 100644 index 000000000000..4bc116c25a42 --- /dev/null +++ b/.changes/fix-nsis-uninstall-delete-app-data.md @@ -0,0 +1,5 @@ +--- +'tauri-bundler': 'patch:bug' +--- + +On Windows, Fix NSIS uninstaller deleting the wrong application data if the delete the application data checkbox is checked. diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 83f6ce504e07..356fdcde1d7a 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -645,12 +645,6 @@ Section Uninstall ; Remove desktop shortcuts Delete "$DESKTOP\${MAINBINARYNAME}.lnk" - ; Delete app data - ${If} $DeleteAppDataCheckboxState == 1 - RmDir /r "$APPDATA\${BUNDLEID}" - RmDir /r "$LOCALAPPDATA\${BUNDLEID}" - ${EndIf} - ; Remove registry information for add/remove programs !if "${INSTALLMODE}" == "both" DeleteRegKey SHCTX "${UNINSTKEY}" @@ -662,6 +656,13 @@ Section Uninstall DeleteRegValue HKCU "${MANUPRODUCTKEY}" "Installer Language" + ; Delete app data + ${If} $DeleteAppDataCheckboxState == 1 + SetShellVarContext current + RmDir /r "$APPDATA\${BUNDLEID}" + RmDir /r "$LOCALAPPDATA\${BUNDLEID}" + ${EndIf} + ${GetOptions} $CMDLINE "/P" $R0 IfErrors +2 0 SetAutoClose true