{"record":{"id":"6b1bfcb17ee81b40","repo":"Devolutions/UniGetUI","slug":"this-package-cannot-be-installed-from-an-elevated","errorCode":null,"errorMessage":"This package cannot be installed from an elevated context.Please run UniGetUI as a regular user and try again.","messagePattern":"This package cannot be installed from an elevated context\\.Please run UniGetUI as a regular user and try again\\.","errorType":"exception","errorClass":"UnauthorizedAccessException","httpStatus":null,"severity":"error","filePath":"src/UniGetUI.PackageEngine.Managers.WinGet/Helpers/WinGetPkgOperationHelper.cs","lineNumber":207,"sourceCode":"                operation\n            );\n            if (\n                installOptions?.ElevationRequirement\n                is ElevationRequirement.ElevationRequired\n                    or ElevationRequirement.ElevatesSelf\n            )\n            {\n                Logger.Info(\n                    $\"WinGet package {package.Id} requires elevation, forcing administrator rights...\"\n                );\n                package.OverridenOptions.RunAsAdministrator = true;\n            }\n            else if (\n                installOptions?.ElevationRequirement is ElevationRequirement.ElevationProhibited\n            )\n            {\n                if (CoreTools.IsAdministrator())\n                    throw new UnauthorizedAccessException(\n                        CoreTools.Translate(\n                            \"This package cannot be installed from an elevated context.\"\n                        )\n                            + CoreTools.Translate(\n                                \"Please run UniGetUI as a regular user and try again.\"\n                            )\n                    );\n\n                if (options.RunAsAdministrator)\n                    throw new UnauthorizedAccessException(\n                        CoreTools.Translate(\n                            \"This package cannot be installed from an elevated context.\"\n                        )\n                            + CoreTools.Translate(\n                                \"Please check the installation options for this package and try again\"\n                            )\n                    );\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.PackageEngine.Managers.WinGet/Helpers/WinGetPkgOperationHelper.cs#L189-L225","documentation":"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.","triggerScenarios":"Installing/upgrading a WinGet package whose manifest marks ElevationRequirement as ElevationProhibited while UniGetUI was launched as administrator.","commonSituations":"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.","solutions":["Relaunch UniGetUI as a regular (non-elevated) user and retry the install.","Do not launch UniGetUI via 'Run as administrator'.","In an automated/elevated context, skip packages whose ElevationRequirement is ElevationProhibited."],"exampleFix":"// before: launched as admin -> throw\n// after (caller guard): skip prohibited packages when elevated\nif (CoreTools.IsAdministrator() &&\n    pkgInstallOptions?.ElevationRequirement is ElevationRequirement.ElevationProhibited)\n    continue; // skip; cannot install elevated","handlingStrategy":"validation","validationCode":"// Caller guard: skip prohibited packages when elevated.\nvar inst = NativePackageHandler.GetInstallationOptions(pkg, options, op);\nif (CoreTools.IsAdministrator() &&\n    inst?.ElevationRequirement is ElevationRequirement.ElevationProhibited)\n    return OperationVeredict.Skipped;","typeGuard":"static bool ProhibitsElevation(InstallationOptions? o) =>\n    o?.ElevationRequirement is ElevationRequirement.ElevationProhibited;","tryCatchPattern":null,"preventionTips":["Do not launch UniGetUI as administrator for per-user/Store packages.","Filter ElevationProhibited packages out of batch operations when elevated.","Surface a clear 'relaunch as regular user' message to the end user."],"tags":["winget","elevation","unauthorized-access","windows","admin"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}