public interface IDesktopPrivilegedActions Runs declared privileged actions with the platform's authorization.
Methods
RunAsync
ValueTask<PlatformResult<PrivilegedActionCompletion>> RunAsync(PrivilegedActionRequest request, CancellationToken cancellationToken = default) Asks for authorization and runs the action's program as the administrator.
Exceptions
ArgumentExceptionThe action is not one this provider declares, or the arguments are not within it.
Remarks
Success means the program ran; check PrivilegedActionCompletion.ExitCode for its own outcome. Authorization refused by policy is Failed with PlatformFailureCode.PermissionDenied; the user dismissing the authentication dialog is PlatformFailureCode.UserDismissed. No authorization service or authentication agent is Unavailable. A program that is missing or can be replaced by other users is PlatformFailureCode.InvalidData, and is never started.
Cancellation before the program starts stops the authorization and throws OperationCanceledException. Once the program runs as the administrator it cannot be stopped from the application: cancellation closes its standard input, which a cooperating program treats as a request to stop, and the result reports how it actually ended.