Skip to content

Add elevation support to RunCommand#7

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/add-verb-support-process-CpCPi
May 13, 2026
Merged

Add elevation support to RunCommand#7
matt-edmondson merged 2 commits into
mainfrom
claude/add-verb-support-process-CpCPi

Conversation

@matt-edmondson
Copy link
Copy Markdown
Contributor

Summary

  • Adds an Elevation enum (Default, Elevated) and overloads to Execute/ExecuteAsync that accept it.
  • On Windows, Elevation.Elevated launches the process with the runas verb via UseShellExecute = true, prompting the user for UAC consent. Output redirection is disabled in this mode because UseShellExecute is incompatible with RedirectStandardOutput/Error, so the OutputHandler is not invoked when elevated.
  • On non-Windows, the value is a no-op — callers should prefix the command with sudo themselves. Auto-prefixing was rejected as surprising and brittle for non-interactive sudo configurations.

Test plan

  • Verify a non-elevated call still streams stdout/stderr to the OutputHandler (existing tests cover this path).
  • On Windows, run RunCommand.Execute("whoami /groups", Elevation.Elevated) and confirm the UAC prompt appears and the process exits 0.
  • On Windows with Elevation.Elevated + an OutputHandler, confirm the handler is not invoked (documented behavior) and the exit code still propagates.
  • On Linux/macOS, confirm Elevation.Elevated runs identically to Elevation.Default (flag is ignored).

Generated by Claude Code

claude added 2 commits May 13, 2026 03:29
Adds an Elevation enum and overloads to Execute/ExecuteAsync that let
callers request elevated privileges. On Windows, Elevation.Elevated
launches the process with the runas verb via UseShellExecute, which
triggers a UAC prompt; output redirection is disabled in that mode
since it is incompatible with UseShellExecute. On non-Windows the
value is a no-op, leaving sudo prefixing to the caller.
Replaces the early return in the elevated branch with an if/else so
the method has one exit point, making the control flow easier to follow.
@matt-edmondson matt-edmondson merged commit e4c8e40 into main May 13, 2026
1 check passed
@matt-edmondson matt-edmondson deleted the claude/add-verb-support-process-CpCPi branch May 13, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants