Joining command fragments with '; ' splits Start-Process mid-call
args quoting · case
Affectsnode, powershell 51, pwsh 7, windows
Fails assilent
Mechanismstatement terminator
Safe fixspace join params
Symptom
Section titled “Symptom”An elevation launcher builds one Start-Process invocation from string
fragments and joins them with "; ". The elevated process starts — but without
its arguments and without the UAC verb, so the elevated action silently does the
wrong thing (or nothing).
// Generator code building a PowerShell command line:const cmd = ["Start-Process -FilePath 'app.exe'", "-ArgumentList 'install'", "-Verb RunAs"].join("; ");// Produces: Start-Process -FilePath 'app.exe'; -ArgumentList 'install'; -Verb RunAs// → Start-Process runs with NO args; the rest are separate (broken) statements.; is PowerShell’s statement terminator. A generator that joins PARAMETER
fragments of one call with "; " inserts statement boundaries mid-command.
Each fragment after the first is parsed as a new statement starting with a
parameter token — a parse error at best, a silently degraded Start-Process
at worst.
Workaround
Section titled “Workaround”- Join parameter tokens of a single call with spaces (or build an array and
splat); place
;only BETWEEN complete statements. - The fix joined fragments with “” and kept
;only after the completeStart-Process ... -Wait.