feat(rustdesk): remove auto-run/atalho para evitar abrir GUI ao iniciar Raven
This commit is contained in:
parent
ccd8642629
commit
e8b58187c9
2 changed files with 55 additions and 0 deletions
|
|
@ -433,6 +433,8 @@ fn ensure_service_running(exe_path: &Path) -> Result<(), RustdeskError> {
|
|||
Err(error) => Err(error),
|
||||
};
|
||||
|
||||
remove_rustdesk_autorun_artifacts();
|
||||
|
||||
// Revalida se o serviço realmente subiu; se não, reinstala e tenta novamente.
|
||||
match query_service_state() {
|
||||
Some(state) if state.eq_ignore_ascii_case("running") => Ok(()),
|
||||
|
|
@ -492,6 +494,58 @@ fn query_service_state() -> Option<String> {
|
|||
None
|
||||
}
|
||||
|
||||
fn remove_rustdesk_autorun_artifacts() {
|
||||
// Remove atalhos de inicialização automática para evitar abrir GUI a cada boot/login.
|
||||
let mut startup_paths: Vec<PathBuf> = Vec::new();
|
||||
if let Ok(appdata) = env::var("APPDATA") {
|
||||
startup_paths.push(
|
||||
Path::new(&appdata)
|
||||
.join("Microsoft")
|
||||
.join("Windows")
|
||||
.join("Start Menu")
|
||||
.join("Programs")
|
||||
.join("Startup")
|
||||
.join("RustDesk.lnk"),
|
||||
);
|
||||
}
|
||||
startup_paths.push(
|
||||
Path::new("C:\\ProgramData")
|
||||
.join("Microsoft")
|
||||
.join("Windows")
|
||||
.join("Start Menu")
|
||||
.join("Programs")
|
||||
.join("Startup")
|
||||
.join("RustDesk.lnk"),
|
||||
);
|
||||
|
||||
for path in startup_paths {
|
||||
if path.exists() {
|
||||
match fs::remove_file(&path) {
|
||||
Ok(_) => log_event(&format!("Atalho de inicialização do RustDesk removido: {}", path.display())),
|
||||
Err(error) => log_event(&format!(
|
||||
"Falha ao remover atalho de inicialização do RustDesk ({}): {}",
|
||||
path.display(),
|
||||
error
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for hive in ["HKCU", "HKLM"] {
|
||||
let reg_path = format!(r"{}\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", hive);
|
||||
let status = hidden_command("reg")
|
||||
.args(["delete", ®_path, "/v", "RustDesk", "/f"])
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.status();
|
||||
if let Ok(code) = status {
|
||||
if code.success() {
|
||||
log_event(&format!("Entrada de auto-run RustDesk removida de {}", reg_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn stop_rustdesk_processes() -> Result<(), RustdeskError> {
|
||||
if let Err(error) = try_stop_service() {
|
||||
log_event(&format!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue