Skip to content

UseShellExecute on macOS passes Arguments to open instead of specified filename #26640

@SteveL-MSFT

Description

@SteveL-MSFT

Using PSCore6:

$si = [System.Diagnostics.ProcessStartInfo]::new()
$si.UseShellExecute = $true
$si.FileName = (Get-Command pwsh).Source
$si.Arguments = "-c 1+1;read-host"
[System.Diagnostics.Process]::Start($si)

Expected:

Start new instance of PowerShell outputting answer of 2 and waiting for Enter, then exit.

Actual:

Help for open command is displayed since -c is not valid.

When using open, arguments to the executable are passed as --args <arguments>

The above script works as expected on Windows.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions