{"record":{"id":"89b7986f29b99f28","repo":"tonhowtf/omniget","slug":"essa-regra-precisa-do-omniget-aberto-como-administrador","errorCode":null,"errorMessage":"essa regra precisa do OmniGet aberto como administrador","messagePattern":"essa regra precisa do OmniGet aberto como administrador","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/win_tweaks.rs","lineNumber":612,"sourceCode":"\n/// Aplica (`enable`) ou reverte uma regra. Guarda o valor anterior em\n/// `<app_data>/tools/win_tweaks_backup.json` para o botão \"restaurar\".\n#[allow(unused_mut, unused_variables)]\npub async fn apply(id: &str, enable: bool) -> anyhow::Result<Rule> {\n    let mut rule = rules()\n        .into_iter()\n        .find(|r| r.id == id)\n        .ok_or_else(|| anyhow!(\"regra desconhecida: {}\", id))?;\n    #[cfg(not(target_os = \"windows\"))]\n    {\n        let _ = enable;\n        let _ = &mut rule;\n        Err(anyhow!(\"esses ajustes so existem no Windows\"))\n    }\n    #[cfg(target_os = \"windows\")]\n    {\n        if rule.requires_admin && !is_admin().await {\n            return Err(anyhow!(\n                \"essa regra precisa do OmniGet aberto como administrador\"\n            ));\n        }\n        if let Some(prev) = reg_query(&rule.key, &rule.name).await {\n            backup_store(&rule.id, &prev);\n        }\n        let target = if enable {\n            rule.on.clone()\n        } else {\n            restore_value(&rule)\n        };\n        reg_set(&rule.key, &rule.name, &target).await?;\n        rule.applied = Some(enable);\n        Ok(rule)\n    }\n}\n\n#[cfg(target_os = \"windows\")]","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/win_tweaks.rs#L594-L630","documentation":"win_tweaks::apply refuses to run a tweak rule on non-admin sessions. When a rule has requires_admin set, the code checks is_admin().await and fails fast with this Portuguese message before touching the registry, since applying the tweak (and even backing up the previous value) needs elevated rights.","triggerScenarios":"Calling apply(rule) with a rule whose requires_admin field is true while the OmniGet/Tauri process was launched without administrator elevation, on Windows.","commonSituations":"User double-clicks the app normally (no UAC elevation) and tries registry-level tweaks like disabling telemetry or Defender settings; CI or scripted invocations of the tweaks tool without an elevated shell.","solutions":["Relaunch OmniGet as administrator (right-click > Run as administrator) and retry the tweak.","Pick a tweak rule with requires_admin == false if the goal can be achieved per-user (HKCU instead of HKLM).","Have the app trigger a UAC elevation prompt (runas) before calling apply.","Surface rule.requires_admin in the UI beforehand so users know elevation is needed."],"exampleFix":"// before\nif rule.requires_admin && !is_admin().await { return Err(anyhow!(\"essa regra precisa do OmniGet aberto como administrador\")); }\n// after\nif rule.requires_admin && !is_admin().await {\n    return Err(anyhow!(\"essa regra precisa do OmniGet aberto como administrador\"));\n}\n// caller: start the app elevated: omniget.exe via an elevated shortcut or ShellExecute(runas)","handlingStrategy":"validation","validationCode":"// caller side, before apply\nif rule.requires_admin && !is_elevated() {\n    prompt_uac_relaunch();\n    return;\n}\napply(rule).await?;","typeGuard":"fn needs_admin(rule: &TweakRule) -> bool { rule.requires_admin }","tryCatchPattern":null,"preventionTips":["Check rule.requires_admin in the UI and show a shield badge before the user clicks apply.","Ship an elevated launcher/shortcut for OmniGet.","Prefer HKCU-scope tweaks when admin rights are unavailable.","Test tweaks from both elevated and non-elevated sessions."],"tags":["windows","admin","elevation","registry-tweaks"],"backgroundTag":"insufficient-permissions","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"}