mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-26 14:21:14 +08:00
fix windows uninstall can not delete the installation directory
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
492ca411e9
commit
69e95bc245
@ -976,7 +976,7 @@ fn get_after_install(exe: &str) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn install_me(options: &str, path: String, silent: bool, debug: bool) -> ResultType<()> {
|
pub fn install_me(options: &str, path: String, silent: bool, debug: bool) -> ResultType<()> {
|
||||||
let uninstall_str = get_uninstall();
|
let uninstall_str = get_uninstall(false);
|
||||||
let mut path = path.trim_end_matches('\\').to_owned();
|
let mut path = path.trim_end_matches('\\').to_owned();
|
||||||
let (subkey, _path, start_menu, exe) = get_default_install_info();
|
let (subkey, _path, start_menu, exe) = get_default_install_info();
|
||||||
let mut exe = exe;
|
let mut exe = exe;
|
||||||
@ -1188,30 +1188,35 @@ pub fn run_after_install() -> ResultType<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_before_uninstall() -> ResultType<()> {
|
pub fn run_before_uninstall() -> ResultType<()> {
|
||||||
run_cmds(get_before_uninstall(), true, "before_install")
|
run_cmds(get_before_uninstall(true), true, "before_install")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_before_uninstall() -> String {
|
fn get_before_uninstall(kill_self: bool) -> String {
|
||||||
let app_name = crate::get_app_name();
|
let app_name = crate::get_app_name();
|
||||||
let ext = app_name.to_lowercase();
|
let ext = app_name.to_lowercase();
|
||||||
|
let filter = if kill_self {
|
||||||
|
"".to_string()
|
||||||
|
} else {
|
||||||
|
format!(" /FI \"PID ne {}\"", get_current_pid())
|
||||||
|
};
|
||||||
format!(
|
format!(
|
||||||
"
|
"
|
||||||
chcp 65001
|
chcp 65001
|
||||||
sc stop {app_name}
|
sc stop {app_name}
|
||||||
sc delete {app_name}
|
sc delete {app_name}
|
||||||
taskkill /F /IM {broker_exe}
|
taskkill /F /IM {broker_exe}
|
||||||
taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\"
|
taskkill /F /IM {app_name}.exe{filter}
|
||||||
reg delete HKEY_CLASSES_ROOT\\.{ext} /f
|
reg delete HKEY_CLASSES_ROOT\\.{ext} /f
|
||||||
netsh advfirewall firewall delete rule name=\"{app_name} Service\"
|
netsh advfirewall firewall delete rule name=\"{app_name} Service\"
|
||||||
",
|
",
|
||||||
app_name = app_name,
|
app_name = app_name,
|
||||||
broker_exe = crate::win_privacy::INJECTED_PROCESS_EXE,
|
broker_exe = crate::win_privacy::INJECTED_PROCESS_EXE,
|
||||||
ext = ext,
|
ext = ext,
|
||||||
cur_pid = get_current_pid(),
|
filter = filter,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_uninstall() -> String {
|
fn get_uninstall(kill_self: bool) -> String {
|
||||||
let (subkey, path, start_menu, _) = get_install_info();
|
let (subkey, path, start_menu, _) = get_install_info();
|
||||||
format!(
|
format!(
|
||||||
"
|
"
|
||||||
@ -1222,7 +1227,7 @@ fn get_uninstall() -> String {
|
|||||||
if exist \"%PUBLIC%\\Desktop\\{app_name}.lnk\" del /f /q \"%PUBLIC%\\Desktop\\{app_name}.lnk\"
|
if exist \"%PUBLIC%\\Desktop\\{app_name}.lnk\" del /f /q \"%PUBLIC%\\Desktop\\{app_name}.lnk\"
|
||||||
if exist \"%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\"
|
if exist \"%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(),
|
before_uninstall=get_before_uninstall(kill_self),
|
||||||
subkey=subkey,
|
subkey=subkey,
|
||||||
app_name = crate::get_app_name(),
|
app_name = crate::get_app_name(),
|
||||||
path = path,
|
path = path,
|
||||||
@ -1231,7 +1236,7 @@ fn get_uninstall() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn uninstall_me() -> ResultType<()> {
|
pub fn uninstall_me() -> ResultType<()> {
|
||||||
run_cmds(get_uninstall(), true, "uninstall")
|
run_cmds(get_uninstall(true), true, "uninstall")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_cmds(cmds: String, ext: &str, tip: &str) -> ResultType<std::path::PathBuf> {
|
fn write_cmds(cmds: String, ext: &str, tip: &str) -> ResultType<std::path::PathBuf> {
|
||||||
|
Loading…
Reference in New Issue
Block a user