Fix commandline quoting when elevating new tabs #20939
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 290 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.339
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #20939"
general
weight: 0.35
DHowett
Summary of the Pull Request
Fixes how the commandline is passed to the elevated window when opening an elevated profile from an unelevated one. Today
pwsh.exe -NoLogoarrives as a single argument ("pwsh.exe -NoLogo") and fails with 0x80070002.References and Relevant Issues
#12597, possibly #14861
Detailed Description of the Pull Request / Additional comments
ToCommandline()wrapped the whole commandline in one pair of quotes without escaping. The elevated instance parses it withCommandLineToArgvW, so the commandline came back as one quoted argument, and a quoted path like"C:\Program Files\..."was split at the first space.The commandline is now appended unquoted after
--, escaping only;so it isn't treated as a subcommand delimiter. The receiver then splits it back into the original arguments, the same way it does forwt new-tab -- <commandline>.Known pre-existing limitation, also with direct
wtusage: some quoting (e.g.\","") isn't preserved exactly when args are re-joined; I can address that in a follow-up.To reproduce: add
"elevate": trueto the Command Prompt profile, then from an unelevated shell runwt -p "Command Prompt" cmd.exe /k echo hi. The elevated window fails to launch"cmd.exe /k echo hi"with error 0x80070002.I used an AI agent (Copilot CLI + Claude Opus 5.5) to help investigate and write this change. I reviewed, built, and tested it myself.
Validation Steps Performed
TestGenerateCommandlineand added a;case. All SettingsModel unit tests pass.TestElevatedCommandlineRoundTripto LocalTests. It serializesNewTerminalArgswithToCommandline(), parses the result like the elevated instance does, and checks the commandline is unchanged. It fails without the fix.-
pwsh.exe -NoLogo -NoProfile -EncodedCommand ...-
"C:\Program Files\PowerShell\7\pwsh.exe" -NoExit -Command "echo 'a b'\; echo c"Both launched correctly. Both fail on the current release.
PR Checklist
- If checked, please file a pull request on our docs repo and link it here: #xxx