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