Skip to main content

UtilityApiError

Electron APIs / utility / UtilityApiError

The value a failed elevation call rejects with: installHighElevationHelper(), isHighElevationHelperInstalled(), canInjectElevated(), installElevationBroker() and uninstallElevationBroker().

It is a plain object, not an Error instance: err instanceof Error is false, and there is no stack trace.

Example​

try {
await api.installElevationBroker();
} catch (err) {
const { message, exitCode } = err as UtilityApiError;
if (exitCode === 1223) {
console.warn("User cancelled UAC prompt");
} else {
console.error("Broker install failed:", message, exitCode);
}
}

Properties​

PropertyModifierTypeDescription
exitCode?readonlynumberExit code of the elevated installer process. Only set by the calls that prompt for UAC (installHighElevationHelper(), installElevationBroker() and uninstallElevationBroker()), and only when the installer actually ran - it is absent when the call failed before that, e.g. a missing helper binary. 1223 (ERROR_CANCELLED) means the user cancelled the UAC prompt.
messagereadonlystringDescribes the failure.