|
|
|
@ -728,6 +728,12 @@ fn copy_files_and_run<R: Read + Seek>(
|
|
|
|
|
// extract the msi
|
|
|
|
|
extractor.extract_into(&tmp_dir)?;
|
|
|
|
|
|
|
|
|
|
let system_root = std::env::var("SYSTEMROOT");
|
|
|
|
|
let powershell_path = system_root.as_ref().map_or_else(
|
|
|
|
|
|_| "powershell.exe".to_string(),
|
|
|
|
|
|p| format!("{p}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let paths = read_dir(&tmp_dir)?;
|
|
|
|
|
|
|
|
|
|
for path in paths {
|
|
|
|
@ -735,10 +741,31 @@ fn copy_files_and_run<R: Read + Seek>(
|
|
|
|
|
// we support 2 type of files exe & msi for now
|
|
|
|
|
// If it's an `exe` we expect an installer not a runtime.
|
|
|
|
|
if found_path.extension() == Some(OsStr::new("exe")) {
|
|
|
|
|
// we need to wrap the installer path in quotes for Start-Process
|
|
|
|
|
let mut installer_arg = std::ffi::OsString::new();
|
|
|
|
|
installer_arg.push("\"");
|
|
|
|
|
installer_arg.push(&found_path);
|
|
|
|
|
installer_arg.push("\"");
|
|
|
|
|
|
|
|
|
|
// Run the EXE
|
|
|
|
|
Command::new(found_path)
|
|
|
|
|
.args(config.tauri.bundle.updater.windows.install_mode.nsis_args())
|
|
|
|
|
.args(&updater_config.installer_args)
|
|
|
|
|
Command::new(powershell_path)
|
|
|
|
|
.args(["-NoProfile", "-WindowStyle", "Hidden"])
|
|
|
|
|
.args(["Start-Process"])
|
|
|
|
|
.arg(found_path)
|
|
|
|
|
.arg("-ArgumentList")
|
|
|
|
|
.arg(
|
|
|
|
|
[
|
|
|
|
|
config.tauri.bundle.updater.windows.install_mode.nsis_args(),
|
|
|
|
|
updater_config
|
|
|
|
|
.installer_args
|
|
|
|
|
.iter()
|
|
|
|
|
.map(AsRef::as_ref)
|
|
|
|
|
.collect::<Vec<_>>()
|
|
|
|
|
.as_slice(),
|
|
|
|
|
]
|
|
|
|
|
.concat()
|
|
|
|
|
.join(", "),
|
|
|
|
|
)
|
|
|
|
|
.spawn()
|
|
|
|
|
.expect("installer failed to start");
|
|
|
|
|
|
|
|
|
@ -808,13 +835,8 @@ fn copy_files_and_run<R: Read + Seek>(
|
|
|
|
|
msiexec_args.extend(updater_config.installer_args.clone());
|
|
|
|
|
|
|
|
|
|
// run the installer and relaunch the application
|
|
|
|
|
let system_root = std::env::var("SYSTEMROOT");
|
|
|
|
|
let powershell_path = system_root.as_ref().map_or_else(
|
|
|
|
|
|_| "powershell.exe".to_string(),
|
|
|
|
|
|p| format!("{p}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"),
|
|
|
|
|
);
|
|
|
|
|
let powershell_install_res = Command::new(powershell_path)
|
|
|
|
|
.args(["-NoProfile", "-windowstyle", "hidden"])
|
|
|
|
|
.args(["-NoProfile", "-WindowStyle", "Hidden"])
|
|
|
|
|
.args([
|
|
|
|
|
"Start-Process",
|
|
|
|
|
"-Wait",
|
|
|
|
|