From 2b960dfd9fdc995bd6474958c05783ff53b64b7e Mon Sep 17 00:00:00 2001 From: animesh chaudhri <111721851+animeshchaudhri@users.noreply.github.com> Date: Mon, 17 Mar 2025 00:58:10 +0530 Subject: [PATCH] feat(uninstaller): remove autostart entry during uninstallation (#12643) * feat(uninstaller): remove autostart entry during uninstallation Signed-off-by: animeshchaudri * add change file * check when not updating * delete registry value only if install mode is "currentUser" --------- Signed-off-by: animeshchaudri Co-authored-by: Lucas Nogueira --- .changes/remove-autostart-nsis-uninstall.md | 5 +++++ .../src/bundle/windows/nsis/installer.nsi | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .changes/remove-autostart-nsis-uninstall.md diff --git a/.changes/remove-autostart-nsis-uninstall.md b/.changes/remove-autostart-nsis-uninstall.md new file mode 100644 index 000000000..c79dc83c4 --- /dev/null +++ b/.changes/remove-autostart-nsis-uninstall.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": patch:bug +--- + +Remove the autostart plugin registry entry when the app is uninstalled (NSIS only). diff --git a/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi b/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi index 8ed4adc0b..556aed8e6 100644 --- a/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi +++ b/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi @@ -835,6 +835,16 @@ Section Uninstall DeleteRegKey HKCU "${UNINSTKEY}" !endif + ; Removes the Autostart entry for ${PRODUCTNAME} from the HKCU Run key if it exists. + ; This ensures the program does not launch automatically after uninstallation if it exists. + ; If it doesn't exist, it does nothing. + ; We do this when not updating (to preserve the registry value on updates) + ; and when the installation is for the current user only - as it is difficult to delete registry values for other users or for the local machine + ${If} $UpdateMode <> 1 + ${AndIf} "${INSTALLMODE}" == "currentUser" + DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCTNAME}" + ${EndIf} + ; Delete app data if the checkbox is selected ; and if not updating ${If} $DeleteAppDataCheckboxState = 1