@@ -706,6 +706,7 @@ impl<R: Runtime> Update<R> {
706706 & self . extract_path ,
707707 self . with_elevated_task ,
708708 & self . app . config ( ) ,
709+ & self . app . env ( ) ,
709710 ) ?;
710711 #[ cfg( not( target_os = "windows" ) ) ]
711712 copy_files_and_run ( archive_buffer, & self . extract_path ) ?;
@@ -805,6 +806,7 @@ fn copy_files_and_run<R: Read + Seek>(
805806 _extract_path : & Path ,
806807 with_elevated_task : bool ,
807808 config : & crate :: Config ,
809+ env : & crate :: Env ,
808810) -> Result {
809811 // FIXME: We need to create a memory buffer with the MSI and then run it.
810812 // (instead of extracting the MSI to a temp path)
@@ -830,6 +832,8 @@ fn copy_files_and_run<R: Read + Seek>(
830832 |p| format ! ( "{p}\\ System32\\ WindowsPowerShell\\ v1.0\\ powershell.exe" ) ,
831833 ) ;
832834
835+ let current_exe_args = env. args . clone ( ) ;
836+
833837 for path in paths {
834838 let found_path = path?. path ( ) ;
835839 // we support 2 type of files exe & msi for now
@@ -842,29 +846,39 @@ fn copy_files_and_run<R: Read + Seek>(
842846 installer_path. push ( "\" " ) ;
843847
844848 let installer_args = [
845- config. tauri . updater . windows . install_mode . nsis_args ( ) ,
849+ config
850+ . tauri
851+ . updater
852+ . windows
853+ . install_mode
854+ . nsis_args ( )
855+ . iter ( )
856+ . map ( ToString :: to_string)
857+ . collect ( ) ,
858+ vec ! [ "/ARGS" . to_string( ) ] ,
859+ current_exe_args,
846860 config
847861 . tauri
848862 . updater
849863 . windows
850864 . installer_args
851865 . iter ( )
852- . map ( AsRef :: as_ref)
853- . collect :: < Vec < _ > > ( )
854- . as_slice ( ) ,
866+ . map ( ToString :: to_string)
867+ . collect :: < Vec < _ > > ( ) ,
855868 ]
856869 . concat ( ) ;
857870
858871 // Run the EXE
859872 let mut cmd = Command :: new ( powershell_path) ;
860873 cmd
861- . args ( [ "-NoProfile" , "-WindowStyle" , "Hidden" ] )
862- . args ( [ "Start-Process" ] )
874+ . args ( [ "-NoProfile" , "-WindowStyle" , "Hidden" , "Start-Process" ] )
863875 . arg ( installer_path) ;
864876 if !installer_args. is_empty ( ) {
865877 cmd. arg ( "-ArgumentList" ) . arg ( installer_args. join ( ", " ) ) ;
866878 }
867- cmd. spawn ( ) . expect ( "installer failed to start" ) ;
879+ cmd
880+ . spawn ( )
881+ . expect ( "Running NSIS installer from powershell has failed to start" ) ;
868882
869883 exit ( 0 ) ;
870884 } else if found_path. extension ( ) == Some ( OsStr :: new ( "msi" ) ) {
@@ -908,10 +922,10 @@ fn copy_files_and_run<R: Read + Seek>(
908922 }
909923
910924 // we need to wrap the current exe path in quotes for Start-Process
911- let mut current_exe_arg = std:: ffi:: OsString :: new ( ) ;
912- current_exe_arg . push ( "\" " ) ;
913- current_exe_arg . push ( current_exe ( ) ?) ;
914- current_exe_arg . push ( "\" " ) ;
925+ let mut current_executable = std:: ffi:: OsString :: new ( ) ;
926+ current_executable . push ( "\" " ) ;
927+ current_executable . push ( dunce :: simplified ( & current_exe ( ) ?) ) ;
928+ current_executable . push ( "\" " ) ;
915929
916930 let mut msi_path = std:: ffi:: OsString :: new ( ) ;
917931 msi_path. push ( "\" \" \" " ) ;
@@ -933,7 +947,9 @@ fn copy_files_and_run<R: Read + Seek>(
933947 . concat ( ) ;
934948
935949 // run the installer and relaunch the application
936- let powershell_install_res = Command :: new ( powershell_path)
950+ let mut powershell_cmd = Command :: new ( powershell_path) ;
951+
952+ powershell_cmd
937953 . args ( [ "-NoProfile" , "-WindowStyle" , "Hidden" ] )
938954 . args ( [
939955 "Start-Process" ,
@@ -946,8 +962,15 @@ fn copy_files_and_run<R: Read + Seek>(
946962 . arg ( & msi_path)
947963 . arg ( format ! ( ", {}, /promptrestart;" , installer_args. join( ", " ) ) )
948964 . arg ( "Start-Process" )
949- . arg ( current_exe_arg)
950- . spawn ( ) ;
965+ . arg ( current_executable) ;
966+
967+ if !current_exe_args. is_empty ( ) {
968+ powershell_cmd
969+ . arg ( "-ArgumentList" )
970+ . arg ( current_exe_args. join ( ", " ) ) ;
971+ }
972+
973+ let powershell_install_res = powershell_cmd. spawn ( ) ;
951974 if powershell_install_res. is_err ( ) {
952975 // fallback to running msiexec directly - relaunch won't be available
953976 // we use this here in case powershell fails in an older machine somehow
0 commit comments