mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
23 lines
506 B
Rust
23 lines
506 B
Rust
#[cfg(windows)]
|
|
pub fn reopen_as_admin() {
|
|
use std::process::{exit, Command};
|
|
|
|
let install = std::env::current_exe().unwrap();
|
|
|
|
println!("Opening as admin: {}", install.to_str().unwrap());
|
|
|
|
Command::new("powershell.exe")
|
|
.arg("powershell")
|
|
.arg(format!(
|
|
"-command \"&{{Start-Process -filepath '{}' -verb runas}}\"",
|
|
install.to_str().unwrap()
|
|
))
|
|
.spawn()
|
|
.expect("Error starting exec as admin");
|
|
|
|
exit(0);
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
pub fn reopen_as_admin() {}
|