Skip to content

Commit 6f46953

Browse files
fix(nsis): run app as normal user (#9944)
1 parent 30bc3d2 commit 6f46953

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.changes/nsis-run-as-user.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch:bug
3+
---
4+
5+
Fix NSIS installer runs the app as admin when using `perMachine` install mode

tooling/bundler/src/bundle/windows/nsis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const NSIS_URL: &str =
3434
#[cfg(target_os = "windows")]
3535
const NSIS_SHA1: &str = "057e83c7d82462ec394af76c87d06733605543d4";
3636
const NSIS_TAURI_UTILS_URL: &str =
37-
"https://github.com/tauri-apps/nsis-tauri-utils/releases/download/nsis_tauri_utils-v0.3.0/nsis_tauri_utils.dll";
38-
const NSIS_TAURI_UTILS_SHA1: &str = "01E48D6429B48B640230C6CE8F257C84758943AA";
37+
"https://github.com/tauri-apps/nsis-tauri-utils/releases/download/nsis_tauri_utils-v0.4.0/nsis_tauri_utils.dll";
38+
const NSIS_TAURI_UTILS_SHA1: &str = "E0FC0951DEB0E5E741DF10328F95C7D6678AD3AA";
3939

4040
#[cfg(target_os = "windows")]
4141
const NSIS_REQUIRED_FILES: &[&str] = &[

tooling/bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,15 @@ Var AppStartMenuFolder
348348
!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(createDesktop)"
349349
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateOrUpdateDesktopShortcut
350350
; Show run app after installation.
351-
!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAINBINARYNAME}.exe"
351+
!define MUI_FINISHPAGE_RUN
352+
!define MUI_FINISHPAGE_RUN_FUNCTION RunMainBinary
352353
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
353354
!insertmacro MUI_PAGE_FINISH
354355

356+
Function RunMainBinary
357+
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" ""
358+
FunctionEnd
359+
355360
; Uninstaller Pages
356361
; 1. Confirm uninstall page
357362
Var DeleteAppDataCheckbox
@@ -617,7 +622,7 @@ Function .onInstSuccess
617622
${GetOptions} $CMDLINE "/R" $R0
618623
${IfNot} ${Errors}
619624
${GetOptions} $CMDLINE "/ARGS" $R0
620-
Exec '"$INSTDIR\${MAINBINARYNAME}.exe" $R0'
625+
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" "$R0"
621626
${EndIf}
622627
${EndIf}
623628
FunctionEnd

0 commit comments

Comments
 (0)