Devolutions/UniGetUI · error · UnauthorizedAccessException

This package cannot be installed from an elevated context.Pl

Error message

This package cannot be installed from an elevated context.Please run UniGetUI as a regular user and try again.

What it means

WinGet ApplyElevationRequirements throws UnauthorizedAccessException when a package's InstallationOptions declares ElevationProhibited AND UniGetUI is currently running elevated (CoreTools.IsAdministrator() is true). The package refuses to install under an admin token; the message tells the user to relaunch as a regular user.

Source

Thrown at src/UniGetUI.PackageEngine.Managers.WinGet/Helpers/WinGetPkgOperationHelper.cs:207

                operation
            );
            if (
                installOptions?.ElevationRequirement
                is ElevationRequirement.ElevationRequired
                    or ElevationRequirement.ElevatesSelf
            )
            {
                Logger.Info(
                    $"WinGet package {package.Id} requires elevation, forcing administrator rights..."
                );
                package.OverridenOptions.RunAsAdministrator = true;
            }
            else if (
                installOptions?.ElevationRequirement is ElevationRequirement.ElevationProhibited
            )
            {
                if (CoreTools.IsAdministrator())
                    throw new UnauthorizedAccessException(
                        CoreTools.Translate(
                            "This package cannot be installed from an elevated context."
                        )
                            + CoreTools.Translate(
                                "Please run UniGetUI as a regular user and try again."
                            )
                    );

                if (options.RunAsAdministrator)
                    throw new UnauthorizedAccessException(
                        CoreTools.Translate(
                            "This package cannot be installed from an elevated context."
                        )
                            + CoreTools.Translate(
                                "Please check the installation options for this package and try again"
                            )
                    );

View on GitHub (pinned to 9b1d7d0eab)

Solutions

  1. Relaunch UniGetUI as a regular (non-elevated) user and retry the install.
  2. Do not launch UniGetUI via 'Run as administrator'.
  3. In an automated/elevated context, skip packages whose ElevationRequirement is ElevationProhibited.

Example fix

// before: launched as admin -> throw
// after (caller guard): skip prohibited packages when elevated
if (CoreTools.IsAdministrator() &&
    pkgInstallOptions?.ElevationRequirement is ElevationRequirement.ElevationProhibited)
    continue; // skip; cannot install elevated
Defensive patterns

Strategy: validation

Validate before calling

// Caller guard: skip prohibited packages when elevated.
var inst = NativePackageHandler.GetInstallationOptions(pkg, options, op);
if (CoreTools.IsAdministrator() &&
    inst?.ElevationRequirement is ElevationRequirement.ElevationProhibited)
    return OperationVeredict.Skipped;

Type guard

static bool ProhibitsElevation(InstallationOptions? o) =>
    o?.ElevationRequirement is ElevationRequirement.ElevationProhibited;

Prevention

When it happens

Trigger: Installing/upgrading a WinGet package whose manifest marks ElevationRequirement as ElevationProhibited while UniGetUI was launched as administrator.

Common situations: User right-clicked 'Run as administrator'; package is a per-user app (e.g. MSIX) that the Store rejects under admin; elevation was inherited from a parent elevated process.

Related errors


AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13). Data as JSON: /api/errors/6b1bfcb17ee81b40. Report an issue: GitHub.