diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index 576e7cb38b9..083df005a2e 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -1896,7 +1896,7 @@ protected override void BeginProcessing() else { // Working Directory not specified -> Assign Current Path. - startInfo.WorkingDirectory = ResolveFilePath(this.SessionState.Path.CurrentFileSystemLocation.Path); + startInfo.WorkingDirectory = PathUtils.ResolveFilePath(this.SessionState.Path.CurrentFileSystemLocation.Path, this, isLiteralPath: true); } if (this.ParameterSetName.Equals("Default")) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 index 0669e78426a..5134705dbea 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 @@ -14,6 +14,8 @@ Describe "Start-Process" -Tag "Feature","RequireAdminOnWindows" { $pingCommand = (Get-Command -CommandType Application ping)[0].Definition $pingDirectory = Split-Path $pingCommand -Parent $tempFile = Join-Path -Path $TestDrive -ChildPath PSTest + $tempDirectory = Join-Path -Path $TestDrive -ChildPath 'PSPath[]' + New-Item $tempDirectory -ItemType Directory -Force $assetsFile = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath SortTest.txt if ($IsWindows) { $pingParam = "-n 2 localhost" @@ -68,6 +70,15 @@ Describe "Start-Process" -Tag "Feature","RequireAdminOnWindows" { $process.Id | Should -BeGreaterThan 1 # $process.ProcessName | Should -Be "ping" } + + It "Should work correctly within an unspecified WorkingDirectory with wildcard-type characters" { + Push-Location -LiteralPath $tempDirectory + $process = Start-Process ping -ArgumentList $pingParam -PassThru -RedirectStandardOutput "$TESTDRIVE/output" @extraArgs + $process.Length | Should -Be 1 + $process.Id | Should -BeGreaterThan 1 + # $process.ProcessName | Should -Be "ping" + Pop-Location + } It "Should handle stderr redirection without error" { $process = Start-Process ping -ArgumentList $pingParam -PassThru -RedirectStandardError $tempFile -RedirectStandardOutput "$TESTDRIVE/output" @extraArgs