From 6f469534b075d901d978c940873f9480f0d10ee0 Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Thu, 6 Jun 2024 08:53:11 +0800 Subject: [PATCH] fix(nsis): run app as normal user (#9944) --- .changes/nsis-run-as-user.md | 5 +++++ tooling/bundler/src/bundle/windows/nsis.rs | 4 ++-- .../bundler/src/bundle/windows/templates/installer.nsi | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 .changes/nsis-run-as-user.md diff --git a/.changes/nsis-run-as-user.md b/.changes/nsis-run-as-user.md new file mode 100644 index 000000000..2ca63383e --- /dev/null +++ b/.changes/nsis-run-as-user.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": patch:bug +--- + +Fix NSIS installer runs the app as admin when using `perMachine` install mode diff --git a/tooling/bundler/src/bundle/windows/nsis.rs b/tooling/bundler/src/bundle/windows/nsis.rs index 3328c9253..e3480d6f7 100644 --- a/tooling/bundler/src/bundle/windows/nsis.rs +++ b/tooling/bundler/src/bundle/windows/nsis.rs @@ -34,8 +34,8 @@ const NSIS_URL: &str = #[cfg(target_os = "windows")] const NSIS_SHA1: &str = "057e83c7d82462ec394af76c87d06733605543d4"; const NSIS_TAURI_UTILS_URL: &str = - "https://github.com/tauri-apps/nsis-tauri-utils/releases/download/nsis_tauri_utils-v0.3.0/nsis_tauri_utils.dll"; -const NSIS_TAURI_UTILS_SHA1: &str = "01E48D6429B48B640230C6CE8F257C84758943AA"; + "https://github.com/tauri-apps/nsis-tauri-utils/releases/download/nsis_tauri_utils-v0.4.0/nsis_tauri_utils.dll"; +const NSIS_TAURI_UTILS_SHA1: &str = "E0FC0951DEB0E5E741DF10328F95C7D6678AD3AA"; #[cfg(target_os = "windows")] const NSIS_REQUIRED_FILES: &[&str] = &[ diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index f64b0fb3b..6c3b84fc5 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -348,10 +348,15 @@ Var AppStartMenuFolder !define MUI_FINISHPAGE_SHOWREADME_TEXT "$(createDesktop)" !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateOrUpdateDesktopShortcut ; Show run app after installation. -!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAINBINARYNAME}.exe" +!define MUI_FINISHPAGE_RUN +!define MUI_FINISHPAGE_RUN_FUNCTION RunMainBinary !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive !insertmacro MUI_PAGE_FINISH +Function RunMainBinary + nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" "" +FunctionEnd + ; Uninstaller Pages ; 1. Confirm uninstall page Var DeleteAppDataCheckbox @@ -617,7 +622,7 @@ Function .onInstSuccess ${GetOptions} $CMDLINE "/R" $R0 ${IfNot} ${Errors} ${GetOptions} $CMDLINE "/ARGS" $R0 - Exec '"$INSTDIR\${MAINBINARYNAME}.exe" $R0' + nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" "$R0" ${EndIf} ${EndIf} FunctionEnd