tonhowtf/omniget · error

essa regra precisa do OmniGet aberto como administrador

Error message

essa regra precisa do OmniGet aberto como administrador

What it means

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.

Solutions

  1. Relaunch OmniGet as administrator (right-click > Run as administrator) and retry the tweak.
  2. Pick a tweak rule with requires_admin == false if the goal can be achieved per-user (HKCU instead of HKLM).
  3. Have the app trigger a UAC elevation prompt (runas) before calling apply.
  4. Surface rule.requires_admin in the UI beforehand so users know elevation is needed.

Example fix

// before
if rule.requires_admin && !is_admin().await { return Err(anyhow!("essa regra precisa do OmniGet aberto como administrador")); }
// after
if rule.requires_admin && !is_admin().await {
    return Err(anyhow!("essa regra precisa do OmniGet aberto como administrador"));
}
// caller: start the app elevated: omniget.exe via an elevated shortcut or ShellExecute(runas)
Defensive patterns

Strategy: validation

Validate before calling

// caller side, before apply
if rule.requires_admin && !is_elevated() {
    prompt_uac_relaunch();
    return;
}
apply(rule).await?;

Type guard

fn needs_admin(rule: &TweakRule) -> bool { rule.requires_admin }

Prevention

When it happens

Trigger: Calling apply(rule) with a rule whose requires_admin field is true while the OmniGet/Tauri process was launched without administrator elevation, on Windows.

Common situations: 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.

Understand the failure class

Background: "You do not have permission" / 403 Forbidden errors: authenticated but not allowed — causes and fixes across open-source libraries — this error's family across 31 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/89b7986f29b99f28. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/win_tweaks.rs:612

/// Aplica (`enable`) ou reverte uma regra. Guarda o valor anterior em
/// `<app_data>/tools/win_tweaks_backup.json` para o botão "restaurar".
#[allow(unused_mut, unused_variables)]
pub async fn apply(id: &str, enable: bool) -> anyhow::Result<Rule> {
    let mut rule = rules()
        .into_iter()
        .find(|r| r.id == id)
        .ok_or_else(|| anyhow!("regra desconhecida: {}", id))?;
    #[cfg(not(target_os = "windows"))]
    {
        let _ = enable;
        let _ = &mut rule;
        Err(anyhow!("esses ajustes so existem no Windows"))
    }
    #[cfg(target_os = "windows")]
    {
        if rule.requires_admin && !is_admin().await {
            return Err(anyhow!(
                "essa regra precisa do OmniGet aberto como administrador"
            ));
        }
        if let Some(prev) = reg_query(&rule.key, &rule.name).await {
            backup_store(&rule.id, &prev);
        }
        let target = if enable {
            rule.on.clone()
        } else {
            restore_value(&rule)
        };
        reg_set(&rule.key, &rule.name, &target).await?;
        rule.applied = Some(enable);
        Ok(rule)
    }
}

#[cfg(target_os = "windows")]

View on GitHub (pinned to 8600b91f42)