{"record":{"id":"9620b7ad22a6a10c","repo":"rustdesk/rustdesk","slug":"failed-to-run-the-update-exe-with-uac-error","errorCode":null,"errorMessage":"Failed to run the update exe with UAC, error: {:?}","messagePattern":"Failed to run the update exe with UAC, error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/platform/windows.rs","lineNumber":3886,"sourceCode":"    } else {\n        log::info!(\"No custom txt found to stage for update.\");\n    }\n\n    Ok(())\n}\n\n// Used for auto update and manual update in the main window.\npub fn update_to(file: &str) -> ResultType<()> {\n    if file.ends_with(\".exe\") {\n        let custom_client_staging_dir = get_custom_client_staging_dir();\n        if crate::is_custom_client() {\n            handle_custom_client_staging_dir_before_update(&custom_client_staging_dir)?;\n        } else {\n            // Clean up any residual staging directory from previous custom client\n            allow_err!(remove_custom_client_staging_dir(&custom_client_staging_dir));\n        }\n        if !run_uac(file, \"--update\")? {\n            bail!(\n                \"Failed to run the update exe with UAC, error: {:?}\",\n                std::io::Error::last_os_error()\n            );\n        }\n    } else if file.ends_with(\".msi\") {\n        if let Err(e) = update_me_msi(file, false) {\n            bail!(\"Failed to run the update msi: {}\", e);\n        }\n    } else {\n        // unreachable!()\n        bail!(\"Unsupported update file format: {}\", file);\n    }\n    Ok(())\n}\n\n// Don't launch tray app when running with `\\qn`.\n// 1. Because `/qn` requires administrator permission and the tray app should be launched with user permission.\n//   Or launching the main window from the tray app will cause the main window to be launched with administrator permission.","sourceCodeStart":3868,"sourceCodeEnd":3904,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540/src/platform/windows.rs#L3868-L3904","documentation":"In `update_to()`, a `.exe` update package is launched elevated via `run_uac(file, \"--update\")`. If the UAC-elevated launch fails (returns false), the code bails reporting `std::io::Error::last_os_error()` — the last Win32 error from the spawn attempt, not a precise cause by itself.","triggerScenarios":"`update_to()` called with a `.exe` path where `run_uac` returns false: user cancels the UAC prompt, UAC is disabled with elevation required, the exe is blocked (SmartScreen/AV), or ShellExecute-like spawn fails.","commonSituations":"User clicks 'No' on the UAC consent dialog; application published via a policy that blocks unsigned exe elevation; exe deleted/locked between download and launch.","solutions":["Re-run the update and accept the UAC prompt","Check `std::io::Error::last_os_error()` value: ERROR_CANCELLED means user denial (expected, not fatal)","Verify the downloaded exe is intact, signed, and not quarantined by AV/SmartScreen","Ensure UAC is enabled and the user account can elevate"],"exampleFix":"// before\nif !run_uac(file, \"--update\")? {\n    bail!(\"Failed to run the update exe with UAC, error: {:?}\", std::io::Error::last_os_error());\n}\n// after\nif !run_uac(file, \"--update\")? {\n    let e = std::io::Error::last_os_error();\n    if e.raw_os_error() == Some(1223 /* ERROR_CANCELLED */) {\n        log::info!(\"User cancelled UAC prompt; update aborted\");\n        return Ok(());\n    }\n    bail!(\"Failed to run the update exe with UAC, error: {e:?}\");\n}","handlingStrategy":"try-catch","validationCode":"// pre-check: package exists and account can elevate\nif !std::path::Path::new(update_exe).is_file() { return; }\nlet admin = is_user_admin(); // e.g. from this crate\nif !admin { log::info!(\"UAC prompt will appear\"); }","typeGuard":null,"tryCatchPattern":"match update_to(file) {\n    Err(e) if e.to_string().contains(\"with UAC\") => {\n        let code = std::io::Error::last_os_error().raw_os_error();\n        if code == Some(1223) { /* user cancelled: not fatal */ }\n        else { log::error!(\"UAC launch failed: {e}\"); }\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Verify the downloaded exe signature/integrity before elevating","Ensure UAC is enabled and the account is in the Administrators group","Keep AV/SmartScreen from quarantining the update package"],"tags":["windows","uac","update","elevation"],"backgroundTag":"permission-denied","analyzedSha":"91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540","analyzedAt":"2026-09-10T19:53:44.083Z","contentChangedAt":"2026-09-10T19:53:44.083Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}