rustdesk/rustdesk · error
Failed to run the update exe with UAC, error: {:?}
Error message
Failed to run the update exe with UAC, error: {:?} What it means
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.
Source
Thrown at src/platform/windows.rs:3886
} else {
log::info!("No custom txt found to stage for update.");
}
Ok(())
}
// Used for auto update and manual update in the main window.
pub fn update_to(file: &str) -> ResultType<()> {
if file.ends_with(".exe") {
let custom_client_staging_dir = get_custom_client_staging_dir();
if crate::is_custom_client() {
handle_custom_client_staging_dir_before_update(&custom_client_staging_dir)?;
} else {
// Clean up any residual staging directory from previous custom client
allow_err!(remove_custom_client_staging_dir(&custom_client_staging_dir));
}
if !run_uac(file, "--update")? {
bail!(
"Failed to run the update exe with UAC, error: {:?}",
std::io::Error::last_os_error()
);
}
} else if file.ends_with(".msi") {
if let Err(e) = update_me_msi(file, false) {
bail!("Failed to run the update msi: {}", e);
}
} else {
// unreachable!()
bail!("Unsupported update file format: {}", file);
}
Ok(())
}
// Don't launch tray app when running with `\qn`.
// 1. Because `/qn` requires administrator permission and the tray app should be launched with user permission.
// Or launching the main window from the tray app will cause the main window to be launched with administrator permission.View on GitHub (pinned to 91c9fccbb0)
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
Example fix
// before
if !run_uac(file, "--update")? {
bail!("Failed to run the update exe with UAC, error: {:?}", std::io::Error::last_os_error());
}
// after
if !run_uac(file, "--update")? {
let e = std::io::Error::last_os_error();
if e.raw_os_error() == Some(1223 /* ERROR_CANCELLED */) {
log::info!("User cancelled UAC prompt; update aborted");
return Ok(());
}
bail!("Failed to run the update exe with UAC, error: {e:?}");
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check: package exists and account can elevate
if !std::path::Path::new(update_exe).is_file() { return; }
let admin = is_user_admin(); // e.g. from this crate
if !admin { log::info!("UAC prompt will appear"); } Try / catch
match update_to(file) {
Err(e) if e.to_string().contains("with UAC") => {
let code = std::io::Error::last_os_error().raw_os_error();
if code == Some(1223) { /* user cancelled: not fatal */ }
else { log::error!("UAC launch failed: {e}"); }
}
Err(e) => return Err(e),
Ok(()) => {}
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- {tip} failed with elevated exit code {exit_code}: {}
- Windows did not return an elevated process handle
- Cannot get parent of current exe file
- Can't get file name of {src_exe}
- Cannot get parent directory of current exe
AI-assisted analysis of rustdesk/rustdesk@91c9fccbb0 (2026-09-10).
Data as JSON: /api/errors/9620b7ad22a6a10c.
Report an issue: GitHub.