diff --git a/src/platform/macos.rs b/src/platform/macos.rs index b57a4d1cd..4ef995a02 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -131,7 +131,7 @@ pub fn is_installed_daemon(prompt: bool) -> bool { .arg(&get_active_username()) .spawn() { - Ok(mut proc) => { + Ok(_) => { std::process::exit(0); } Err(e) => { @@ -157,6 +157,7 @@ pub fn launch(load: bool) { std::process::Command::new("osascript") .arg("-e") .arg(script_body) + .arg(&get_active_username()) .spawn() .ok(); } diff --git a/src/platform/privileges_scripts/load.scpt b/src/platform/privileges_scripts/load.scpt index a370b045e..a725af2bc 100644 --- a/src/platform/privileges_scripts/load.scpt +++ b/src/platform/privileges_scripts/load.scpt @@ -1,6 +1,16 @@ -set sh1 to "launchctl load -w /Library/LaunchDaemons/com.carriez.rustdesk_service.plist;" -set sh2 to "launchctl load -w /Library/LaunchAgents/com.carriez.rustdesk_server.plist;" +on run {user} -do shell script sh1 with prompt "RustDesk want to launch daemon" with administrator privileges -do shell script sh2 + set sh1 to "cp -rf /Users/" & user & "/Library/Preferences/com.carriez.RustDesk/RustDesk.toml /var/root/Library/Preferences/com.carriez.RustDesk/;" + set sh2 to "cp -rf /Users/" & user & "/Library/Preferences/com.carriez.RustDesk/RustDesk2.toml /var/root/Library/Preferences/com.carriez.RustDesk/;" + + set sh3 to "launchctl load -w /Library/LaunchDaemons/com.carriez.rustdesk_service.plist;" + + set sh4 to "launchctl load -w /Library/LaunchAgents/com.carriez.rustdesk_server.plist;" + + set sh to sh1 & sh2 & sh3 + + do shell script sh with prompt "RustDesk want to launch daemon" with administrator privileges + do shell script sh4 + +end run