debug install
This commit is contained in:
parent
77dcbdb32b
commit
e670b7e059
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -921,9 +921,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.9"
|
||||
version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978"
|
||||
checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"once_cell",
|
||||
@ -2571,9 +2571,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
version = "0.5.4"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
@ -4462,9 +4462,9 @@ checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.8.0"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
||||
checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2"
|
||||
|
||||
[[package]]
|
||||
name = "smithay-client-toolkit"
|
||||
@ -4942,9 +4942,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.27"
|
||||
version = "0.1.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921"
|
||||
checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
@ -5025,9 +5025,9 @@ checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.19"
|
||||
version = "0.1.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
|
||||
checksum = "81dee68f85cab8cf68dec42158baf3a79a1cdc065a8b103025965d6ccb7f6cbd"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
11
src/main.rs
11
src/main.rs
@ -97,6 +97,7 @@ fn main() {
|
||||
"desktopicon startmenu",
|
||||
"".to_owned(),
|
||||
false,
|
||||
false,
|
||||
));
|
||||
return;
|
||||
} else if args[0] == "--silent-install" {
|
||||
@ -104,12 +105,9 @@ fn main() {
|
||||
"desktopicon startmenu",
|
||||
"".to_owned(),
|
||||
true,
|
||||
args.len() > 1,
|
||||
));
|
||||
return;
|
||||
} else if args[0] == "--extract" {
|
||||
#[cfg(feature = "with_rc")]
|
||||
hbb_common::allow_err!(crate::rc::extract_resources(&args[1]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if args[0] == "--remove" {
|
||||
@ -197,7 +195,7 @@ fn main() {
|
||||
.about("RustDesk command line tool")
|
||||
.args_from_usage(&args)
|
||||
.get_matches();
|
||||
use hbb_common::{env_logger::*, config::LocalConfig};
|
||||
use hbb_common::env_logger::*;
|
||||
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
|
||||
if let Some(p) = matches.value_of("port-forward") {
|
||||
let options: Vec<String> = p.split(":").map(|x| x.to_owned()).collect();
|
||||
@ -224,7 +222,6 @@ fn main() {
|
||||
remote_host = options[3].clone();
|
||||
}
|
||||
let key = matches.value_of("key").unwrap_or("").to_owned();
|
||||
let token = LocalConfig::get_option("access_token");
|
||||
cli::start_one_port_forward(options[0].clone(), port, remote_host, remote_port, key, token);
|
||||
cli::start_one_port_forward(options[0].clone(), port, remote_host, remote_port, key);
|
||||
}
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ pub fn set_share_rdp(enable: bool) {
|
||||
subkey,
|
||||
if enable { "true" } else { "false" }
|
||||
);
|
||||
run_cmds(cmd, false).ok();
|
||||
run_cmds(cmd, false, "share_rdp").ok();
|
||||
}
|
||||
|
||||
pub fn get_active_username() -> String {
|
||||
@ -835,7 +835,7 @@ pub fn check_update_broker_process() -> ResultType<()> {
|
||||
origin_process_exe = origin_process_exe,
|
||||
cur_exe = cur_exe.to_string_lossy().to_string(),
|
||||
);
|
||||
run_cmds(cmds, false)?;
|
||||
run_cmds(cmds, false, "update_broker")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -876,7 +876,7 @@ pub fn update_me() -> ResultType<()> {
|
||||
lic = register_licence(),
|
||||
);
|
||||
std::thread::sleep(std::time::Duration::from_millis(1000));
|
||||
run_cmds(cmds, false)?;
|
||||
run_cmds(cmds, false, "update")?;
|
||||
std::thread::sleep(std::time::Duration::from_millis(2000));
|
||||
std::process::Command::new(&exe).arg("--tray").spawn().ok();
|
||||
std::process::Command::new(&exe).spawn().ok();
|
||||
@ -905,7 +905,7 @@ fn get_after_install(exe: &str) -> String {
|
||||
", ext=ext, exe=exe, app_name=app_name)
|
||||
}
|
||||
|
||||
pub fn install_me(options: &str, path: String, silent: bool) -> ResultType<()> {
|
||||
pub fn install_me(options: &str, path: String, silent: bool, debug: bool) -> ResultType<()> {
|
||||
let uninstall_str = get_uninstall();
|
||||
let mut path = path.trim_end_matches('\\').to_owned();
|
||||
let (subkey, _path, start_menu, exe) = get_default_install_info();
|
||||
@ -929,7 +929,7 @@ pub fn install_me(options: &str, path: String, silent: bool) -> ResultType<()> {
|
||||
version_build = versions[2];
|
||||
}
|
||||
|
||||
let tmp_path = "C:\\Windows\\temp";
|
||||
let tmp_path = std::env::temp_dir().to_string_lossy().to_string();
|
||||
let mk_shortcut = write_cmds(
|
||||
format!(
|
||||
"
|
||||
@ -945,6 +945,7 @@ oLink.Save
|
||||
exe = exe,
|
||||
),
|
||||
"vbs",
|
||||
"mk_shortcut",
|
||||
)?
|
||||
.to_str()
|
||||
.unwrap_or("")
|
||||
@ -966,6 +967,7 @@ oLink.Save
|
||||
exe = exe,
|
||||
),
|
||||
"vbs",
|
||||
"uninstall_shortcut",
|
||||
)?
|
||||
.to_str()
|
||||
.unwrap_or("")
|
||||
@ -986,6 +988,7 @@ oLink.Save
|
||||
exe = exe,
|
||||
),
|
||||
"vbs",
|
||||
"tray_shortcut",
|
||||
)?
|
||||
.to_str()
|
||||
.unwrap_or("")
|
||||
@ -1042,7 +1045,7 @@ reg add {subkey} /f /v WindowsInstaller /t REG_DWORD /d 0
|
||||
cscript \"{mk_shortcut}\"
|
||||
cscript \"{uninstall_shortcut}\"
|
||||
cscript \"{tray_shortcut}\"
|
||||
copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\\"
|
||||
copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\\"
|
||||
{shortcuts}
|
||||
copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
|
||||
del /f \"{mk_shortcut}\"
|
||||
@ -1079,7 +1082,7 @@ sc delete {app_name}
|
||||
lic=register_licence(),
|
||||
after_install=get_after_install(&exe),
|
||||
);
|
||||
run_cmds(cmds, false)?;
|
||||
run_cmds(cmds, debug, "install")?;
|
||||
std::thread::sleep(std::time::Duration::from_millis(2000));
|
||||
if !silent {
|
||||
std::process::Command::new(&exe).spawn()?;
|
||||
@ -1091,11 +1094,11 @@ sc delete {app_name}
|
||||
|
||||
pub fn run_after_install() -> ResultType<()> {
|
||||
let (_, _, _, exe) = get_install_info();
|
||||
run_cmds(get_after_install(&exe), true)
|
||||
run_cmds(get_after_install(&exe), true, "after_install")
|
||||
}
|
||||
|
||||
pub fn run_before_uninstall() -> ResultType<()> {
|
||||
run_cmds(get_before_uninstall(), true)
|
||||
run_cmds(get_before_uninstall(), true, "before_install")
|
||||
}
|
||||
|
||||
fn get_before_uninstall() -> String {
|
||||
@ -1126,7 +1129,7 @@ fn get_uninstall() -> String {
|
||||
rd /s /q \"{path}\"
|
||||
rd /s /q \"{start_menu}\"
|
||||
del /f /q \"%PUBLIC%\\Desktop\\{app_name}*\"
|
||||
del /f /q \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{app_name} Tray.lnk\"
|
||||
del /f /q \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{app_name} Tray.lnk\"
|
||||
",
|
||||
before_uninstall=get_before_uninstall(),
|
||||
subkey=subkey,
|
||||
@ -1137,17 +1140,12 @@ fn get_uninstall() -> String {
|
||||
}
|
||||
|
||||
pub fn uninstall_me() -> ResultType<()> {
|
||||
run_cmds(get_uninstall(), true)
|
||||
run_cmds(get_uninstall(), true, "uninstall")
|
||||
}
|
||||
|
||||
fn write_cmds(cmds: String, ext: &str) -> ResultType<std::path::PathBuf> {
|
||||
fn write_cmds(cmds: String, ext: &str, tip: &str) -> ResultType<std::path::PathBuf> {
|
||||
let mut tmp = std::env::temp_dir();
|
||||
tmp.push(format!(
|
||||
"{}_{:?}.{}",
|
||||
crate::get_app_name(),
|
||||
cmds.as_ptr(),
|
||||
ext
|
||||
));
|
||||
tmp.push(format!("{}_{}.{}", crate::get_app_name(), tip, ext));
|
||||
let mut file = std::fs::File::create(&tmp)?;
|
||||
// in case cmds mixed with \r\n and \n, make sure all ending with \r\n
|
||||
// in some windows, \r\n required for cmd file to run
|
||||
@ -1170,8 +1168,8 @@ fn to_le(v: &mut [u16]) -> &[u8] {
|
||||
unsafe { v.align_to().1 }
|
||||
}
|
||||
|
||||
fn run_cmds(cmds: String, show: bool) -> ResultType<()> {
|
||||
let tmp = write_cmds(cmds, "bat")?;
|
||||
fn run_cmds(cmds: String, show: bool, tip: &str) -> ResultType<()> {
|
||||
let tmp = write_cmds(cmds, "bat", tip)?;
|
||||
let tmp_fn = tmp.to_str().unwrap_or("");
|
||||
let res = runas::Command::new("cmd")
|
||||
.args(&["/C", &tmp_fn])
|
||||
@ -1348,6 +1346,7 @@ oLink.Save
|
||||
id = id,
|
||||
),
|
||||
"vbs",
|
||||
"connect_shortcut",
|
||||
)?
|
||||
.to_str()
|
||||
.unwrap_or("")
|
||||
|
@ -213,7 +213,9 @@ impl UI {
|
||||
fn install_me(&mut self, _options: String, _path: String) {
|
||||
#[cfg(windows)]
|
||||
std::thread::spawn(move || {
|
||||
allow_err!(crate::platform::windows::install_me(&_options, _path, false));
|
||||
allow_err!(crate::platform::windows::install_me(
|
||||
&_options, _path, false, false
|
||||
));
|
||||
std::process::exit(0);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user