diff --git a/Cargo.lock b/Cargo.lock index 17b02014c..9dee2ec47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6793,7 +6793,7 @@ dependencies = [ "time", "tokio", "url", - "windows 0.54.0", + "windows-sys 0.52.0", "zip", ] @@ -8096,16 +8096,6 @@ dependencies = [ "windows-targets 0.52.4", ] -[[package]] -name = "windows" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" -dependencies = [ - "windows-core 0.54.0", - "windows-targets 0.52.4", -] - [[package]] name = "windows-core" version = "0.51.1" @@ -8124,16 +8114,6 @@ dependencies = [ "windows-targets 0.52.4", ] -[[package]] -name = "windows-core" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" -dependencies = [ - "windows-result", - "windows-targets 0.52.4", -] - [[package]] name = "windows-implement" version = "0.52.0" @@ -8156,15 +8136,6 @@ dependencies = [ "syn 2.0.49", ] -[[package]] -name = "windows-result" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd19df78e5168dfb0aedc343d1d1b8d422ab2db6756d2dc3fef75035402a3f64" -dependencies = [ - "windows-targets 0.52.4", -] - [[package]] name = "windows-sys" version = "0.36.1" diff --git a/plugins/updater/Cargo.toml b/plugins/updater/Cargo.toml index 73cd09922..6159feb26 100644 --- a/plugins/updater/Cargo.toml +++ b/plugins/updater/Cargo.toml @@ -37,11 +37,7 @@ tar = "0.4" [target."cfg(target_os = \"windows\")".dependencies] zip = { version = "0.6", default-features = false } -windows = { version = "0.54", features = [ - "Win32_System_WinRT", - "Win32_UI_Shell", - "Win32_UI_WindowsAndMessaging", -] } +windows-sys = { version = "0.52.0", features = ["Win32_Foundation", "Win32_UI_WindowsAndMessaging"] } [target."cfg(any(target_os = \"macos\", target_os = \"linux\"))".dependencies] flate2 = "1.0.27" diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index a64184b1d..3c0608535 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -514,8 +514,9 @@ impl Update { fn install_inner(&self, bytes: Vec) -> Result<()> { use std::fs; - use windows::{ - core::{w, HSTRING}, + use windows_sys::{ + core::HSTRING, + w, Win32::UI::{Shell::ShellExecuteW, WindowsAndMessaging::SW_SHOW}, }; @@ -575,12 +576,25 @@ impl Update { } else { continue; } - let file = HSTRING::from(found_path.as_os_str()); - let parameters = HSTRING::from(installer_args.join(OsStr::new(" "))); - let ret = - unsafe { ShellExecuteW(None, w!("runas"), &file, ¶meters, None, SW_SHOW) }; - if ret.0 <= 32 { - return Err(Error::Io(windows::core::Error::from_win32().into())); + let file = HSTRING::from(found_path.as_os_str().as_encoded_bytes().as_ptr() as _); + let parameters = HSTRING::from( + installer_args + .join(OsStr::new(" ")) + .as_encoded_bytes() + .as_ptr() as _, + ); + let ret = unsafe { + ShellExecuteW( + 0, + w!("runas"), + file as _, + parameters as _, + std::ptr::null(), + SW_SHOW, + ) + }; + if ret <= 32 { + return Err(Error::Io(std::io::Error::last_os_error())); } std::process::exit(0); }