@@ -709,15 +709,45 @@ fn copy_files_and_run<R: Read + Seek>(
709709
710710 let paths = read_dir ( & tmp_dir) ?;
711711
712+ let system_root = std:: env:: var ( "SYSTEMROOT" ) ;
713+ let powershell_path = system_root. as_ref ( ) . map_or_else (
714+ |_| "powershell.exe" . to_string ( ) ,
715+ |p| format ! ( "{p}\\ System32\\ WindowsPowerShell\\ v1.0\\ powershell.exe" ) ,
716+ ) ;
717+
712718 for path in paths {
713719 let found_path = path?. path ( ) ;
714720 // we support 2 type of files exe & msi for now
715721 // If it's an `exe` we expect an installer not a runtime.
716722 if found_path. extension ( ) == Some ( OsStr :: new ( "exe" ) ) {
723+ // we need to wrap the installer path in quotes for Start-Process
724+ let mut installer_arg = std:: ffi:: OsString :: new ( ) ;
725+ installer_arg. push ( "\" " ) ;
726+ installer_arg. push ( & found_path) ;
727+ installer_arg. push ( "\" " ) ;
728+
717729 // Run the EXE
718- Command :: new ( found_path)
719- . args ( config. tauri . updater . windows . install_mode . nsis_args ( ) )
720- . args ( & config. tauri . updater . windows . installer_args )
730+ Command :: new ( powershell_path)
731+ . args ( [ "-NoProfile" , "-WindowStyle" , "Hidden" ] )
732+ . args ( [ "Start-Process" ] )
733+ . arg ( found_path)
734+ . arg ( "-ArgumentList" )
735+ . arg (
736+ [
737+ config. tauri . updater . windows . install_mode . nsis_args ( ) ,
738+ config
739+ . tauri
740+ . updater
741+ . windows
742+ . installer_args
743+ . iter ( )
744+ . map ( AsRef :: as_ref)
745+ . collect :: < Vec < _ > > ( )
746+ . as_slice ( ) ,
747+ ]
748+ . concat ( )
749+ . join ( ", " ) ,
750+ )
721751 . spawn ( )
722752 . expect ( "installer failed to start" ) ;
723753
@@ -785,13 +815,8 @@ fn copy_files_and_run<R: Read + Seek>(
785815 msiexec_args. extend ( config. tauri . updater . windows . installer_args . clone ( ) ) ;
786816
787817 // run the installer and relaunch the application
788- let system_root = std:: env:: var ( "SYSTEMROOT" ) ;
789- let powershell_path = system_root. as_ref ( ) . map_or_else (
790- |_| "powershell.exe" . to_string ( ) ,
791- |p| format ! ( "{p}\\ System32\\ WindowsPowerShell\\ v1.0\\ powershell.exe" ) ,
792- ) ;
793818 let powershell_install_res = Command :: new ( powershell_path)
794- . args ( [ "-NoProfile" , "-windowstyle " , "hidden " ] )
819+ . args ( [ "-NoProfile" , "-WindowStyle " , "Hidden " ] )
795820 . args ( [
796821 "Start-Process" ,
797822 "-Wait" ,
0 commit comments