{"record":{"id":"ec6d9419dc5922ff","repo":"tonhowtf/omniget","slug":"reg-export-falhou","errorCode":null,"errorMessage":"reg export falhou: {}","messagePattern":"reg export falhou: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/win_registry.rs","lineNumber":164,"sourceCode":"    std::fs::create_dir_all(&dir)?;\n    let safe: String = key\n        .chars()\n        .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })\n        .collect();\n    let file = dir.join(format!(\n        \"{}-{}.reg\",\n        chrono::Local::now().format(\"%Y%m%d-%H%M%S\"),\n        safe.chars().take(80).collect::<String>()\n    ));\n    let o = crate::core::process::command(\"reg\")\n        .arg(\"export\")\n        .arg(key)\n        .arg(&file)\n        .arg(\"/y\")\n        .output()\n        .await?;\n    if !o.status.success() {\n        return Err(anyhow!(\n            \"reg export falhou: {}\",\n            String::from_utf8_lossy(&o.stderr).trim()\n        ));\n    }\n    Ok(file)\n}\n\n/// Expande `%VAR%` e devolve o executável de uma linha de comando do registro\n/// (`\"C:\\x\\a.exe\" /arg`, `C:\\x\\a.exe /arg`, `rundll32 ...`).\npub fn command_exe(cmd: &str) -> Option<PathBuf> {\n    let s = expand_env(cmd.trim());\n    if s.is_empty() {\n        return None;\n    }\n    let candidate = if let Some(rest) = s.strip_prefix('\"') {\n        rest.split('\"').next().unwrap_or(\"\").to_string()\n    } else {\n        // sem aspas: até o primeiro \".exe\" (com espaços no caminho) ou o primeiro token","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/win_registry.rs#L146-L182","documentation":"The `reg export` command that dumps the key to a timestamped .reg file under registry-backups exited non-zero; the {} is reg.exe's stderr. Usually the key does not exist, is not exportable due to permissions, or the backup directory/file could not be written.","triggerScenarios":"Thrown at src-tauri/omniget-core/src/core/tools/win_registry.rs:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the registry key actually exists before attempting a backup/fix","Run the app as administrator for keys under HKEY_LOCAL_MACHINE","Check that the registry-backups folder under the app data dir is writable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}