rustdesk/rustdesk · error
Failed to read {name} from registry key {subkey}: {err}
Error message
Failed to read {name} from registry key {subkey}: {err} What it means
After successfully opening the HKLM subkey, `get_reg_string_of` reads a REG_SZ value as `String`. A missing value maps to `Ok(None)`; any other read/convert failure (wrong value type such as REG_DWORD/REG_EXPAND_SZ, decode error, access issue) bails with this message naming the value and subkey.
Source
Thrown at src/platform/windows.rs:3665
if \"%RUSTDESK_MSI_EXIT_CODE%\"==\"{MSI_EXIT_SUCCESS_REBOOT_REQUIRED}\" echo MSI uninstall succeeded with a reboot recommendation; continuing without reboot.\n\
if \"%RUSTDESK_MSI_EXIT_CODE%\"==\"{MSI_EXIT_SUCCESS_REBOOT_INITIATED}\" echo MSI uninstall succeeded with a reboot request; continuing without forcing reboot.\n\
if not \"%RUSTDESK_MSI_EXIT_CODE%\"==\"0\" if not \"%RUSTDESK_MSI_EXIT_CODE%\"==\"{MSI_EXIT_SUCCESS_REBOOT_REQUIRED}\" if not \"%RUSTDESK_MSI_EXIT_CODE%\"==\"{MSI_EXIT_SUCCESS_REBOOT_INITIATED}\" exit /b %RUSTDESK_MSI_EXIT_CODE%\n\
ver > nul"
)
}
fn get_reg_string_of(subkey: &str, name: &str) -> ResultType<Option<String>> {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let path = subkey.strip_prefix(HKLM_PREFIX).unwrap_or(subkey);
let key = match hklm.open_subkey(path) {
Ok(key) => key,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
Err(err) => bail!("Failed to open registry key {subkey}: {err}"),
};
match key.get_value::<String, _>(name) {
Ok(value) => Ok(Some(value)),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None),
Err(err) => bail!("Failed to read {name} from registry key {subkey}: {err}"),
}
}
fn get_windows_installer_state(subkey: &str) -> ResultType<Option<bool>> {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let path = subkey.strip_prefix(HKLM_PREFIX).unwrap_or(subkey);
let key = match hklm.open_subkey(path) {
Ok(key) => key,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
Err(err) => bail!("Failed to open registry key {subkey}: {err}"),
};
match key.get_value::<u32, _>(REG_NAME_WINDOWS_INSTALLER) {
Ok(value) => Ok(Some(value == MSI_WINDOWS_INSTALLER_VALUE)),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None),
Err(err) => bail!("Failed to read {REG_NAME_WINDOWS_INSTALLER} from {subkey}: {err}"),
}
}
View on GitHub (pinned to 91c9fccbb0)
Solutions
- Inspect the value's type in regedit; if it's not REG_SZ, read it with the appropriate type or treat the entry as unusable
- Check the io error in the message: ERROR_INVALID_PARAMETER / type errors indicate a type mismatch rather than absence
- Repair the entry by reinstalling the referenced application so the uninstall key is rewritten correctly
- If a third party wrote a bad type, delete the stale uninstall subkey and let the installer recreate it
Defensive patterns
Strategy: fallback
Validate before calling
// ensure the value type is REG_SZ before the typed read
let key = hklm.open_subkey(path)?;
let is_string = key.query_value(name)
.map(|v| matches!(v.vtype, REG_SZ))
.unwrap_or(false);
if !is_string { /* treat as missing or read raw */ } Try / catch
match get_reg_string_of(subkey, name) {
Ok(v) => v,
Err(e) if e.to_string().contains("Failed to read") => {
log::warn!("bad value type: {e}"); None
}
Err(e) => return Err(e),
} Prevention
- Check the value's registry type with query_value before a typed get_value
- Repair entries written with the wrong type by third-party installers
- Prefer None/default on read failure for non-critical metadata
- Reinstall the app to regenerate corrupted uninstall values
When it happens
Trigger: Reading a registry value that exists but is not a plain REG_SZ string (e.g. it's REG_DWORD or REG_BINARY), or the string contains invalid UTF-16/UTF-8 that winreg cannot convert to String.
Common situations: Third-party installers writing DisplayVersion/UninstallString as non-string types; corrupted uninstall entries; value written with unusual encoding by another tool.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Failed to read {REG_NAME_WINDOWS_INSTALLER} from MSI uninsta
- Failed to read {REG_NAME_DISPLAY_NAME} from MSI uninstall en
- Failed to open registry key {subkey}: {err}
- Failed to read {REG_NAME_WINDOWS_INSTALLER} from {subkey}: {
- Multiple native MSI uninstall entries were found for {app_na
AI-assisted analysis of rustdesk/rustdesk@91c9fccbb0 (2026-09-10).
Data as JSON: /api/errors/73cfe232ab98860f.
Report an issue: GitHub.