mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-15 20:51:29 +03:00
refact: install printer (#11745)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -269,6 +269,28 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
crate::virtual_display_manager::amyuni_idd::uninstall_driver()
|
crate::virtual_display_manager::amyuni_idd::uninstall_driver()
|
||||||
);
|
);
|
||||||
return None;
|
return None;
|
||||||
|
} else if args[0] == "--install-remote-printer" {
|
||||||
|
#[cfg(windows)]
|
||||||
|
if crate::platform::is_win_10_or_greater() {
|
||||||
|
match remote_printer::install_update_printer(&crate::get_app_name()) {
|
||||||
|
Ok(_) => {
|
||||||
|
log::info!("Remote printer installed/updated successfully");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Failed to install/update the remote printer: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::error!("Win10 or greater required!");
|
||||||
|
}
|
||||||
|
return None;
|
||||||
|
} else if args[0] == "--uninstall-remote-printer" {
|
||||||
|
#[cfg(windows)]
|
||||||
|
if crate::platform::is_win_10_or_greater() {
|
||||||
|
remote_printer::uninstall_printer(&crate::get_app_name());
|
||||||
|
log::info!("Remote printer uninstalled");
|
||||||
|
}
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
@@ -1390,6 +1390,16 @@ copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"%PROGRAMDATA%\\Microsoft\\Windows\
|
|||||||
")
|
")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let install_remote_printer = if install_printer {
|
||||||
|
// No need to use `|| true` here.
|
||||||
|
// The script will not exit even if `--install-remote-printer` panics.
|
||||||
|
format!("\"{}\" --install-remote-printer", &src_exe)
|
||||||
|
} else if crate::platform::is_win_10_or_greater() {
|
||||||
|
format!("\"{}\" --uninstall-remote-printer", &src_exe)
|
||||||
|
} else {
|
||||||
|
"".to_owned()
|
||||||
|
};
|
||||||
|
|
||||||
// Remember to check if `update_me` need to be changed if changing the `cmds`.
|
// Remember to check if `update_me` need to be changed if changing the `cmds`.
|
||||||
// No need to merge the existing dup code, because the code in these two functions are too critical.
|
// No need to merge the existing dup code, because the code in these two functions are too critical.
|
||||||
// New code should be written in a common function.
|
// New code should be written in a common function.
|
||||||
@@ -1418,6 +1428,7 @@ cscript \"{uninstall_shortcut}\"
|
|||||||
{tray_shortcuts}
|
{tray_shortcuts}
|
||||||
{shortcuts}
|
{shortcuts}
|
||||||
copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
|
copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
|
||||||
|
{install_remote_printer}
|
||||||
{dels}
|
{dels}
|
||||||
{import_config}
|
{import_config}
|
||||||
{after_install}
|
{after_install}
|
||||||
@@ -1437,11 +1448,6 @@ copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
|
|||||||
import_config = get_import_config(&exe),
|
import_config = get_import_config(&exe),
|
||||||
);
|
);
|
||||||
run_cmds(cmds, debug, "install")?;
|
run_cmds(cmds, debug, "install")?;
|
||||||
if install_printer {
|
|
||||||
allow_err!(remote_printer::install_update_printer(
|
|
||||||
&crate::get_app_name()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
run_after_run_cmds(silent);
|
run_after_run_cmds(silent);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user