@@ -69,6 +69,19 @@ function Write-SummaryLine {
6969 Write-Host " $Value "
7070}
7171
72+ function Format-ArgumentForProcess {
73+ param (
74+ [Parameter (Mandatory = $true )]
75+ [string ]$Value
76+ )
77+
78+ if ($Value -notmatch ' [\s"]' ) {
79+ return $Value
80+ }
81+
82+ return ' "' + ($Value -replace ' "' , ' \"' ) + ' "'
83+ }
84+
7285function Format-CommandForDisplay {
7386 param (
7487 [Parameter (Mandatory = $true )]
@@ -105,20 +118,35 @@ function Invoke-NativeCommand {
105118
106119 Write-Host (" Running: {0}" -f (Format-CommandForDisplay - FilePath $FilePath - Arguments $Arguments )) - ForegroundColor DarkGray
107120
108- $hadNativePreference = Test-Path variable:PSNativeCommandUseErrorActionPreference
109- if ($hadNativePreference ) {
110- $previousNativePreference = $PSNativeCommandUseErrorActionPreference
111- $PSNativeCommandUseErrorActionPreference = $false
112- }
121+ $stdoutPath = [System.IO.Path ]::GetTempFileName()
122+ $stderrPath = [System.IO.Path ]::GetTempFileName()
123+ $argumentLine = (@ ($Arguments ) | ForEach-Object { Format-ArgumentForProcess $_ }) -join ' '
113124
114125 try {
115- $output = & $FilePath @Arguments 2>&1
116- $exitCode = $LASTEXITCODE
126+ $process = Start-Process - FilePath $FilePath `
127+ - ArgumentList $argumentLine `
128+ - NoNewWindow `
129+ - Wait `
130+ - PassThru `
131+ - RedirectStandardOutput $stdoutPath `
132+ - RedirectStandardError $stderrPath
133+
134+ $stdout = if (Test-Path - LiteralPath $stdoutPath ) {
135+ @ (Get-Content - LiteralPath $stdoutPath - ErrorAction SilentlyContinue)
136+ } else {
137+ @ ()
138+ }
139+ $stderr = if (Test-Path - LiteralPath $stderrPath ) {
140+ @ (Get-Content - LiteralPath $stderrPath - ErrorAction SilentlyContinue)
141+ } else {
142+ @ ()
143+ }
144+
145+ $output = @ ($stdout + $stderr )
146+ $exitCode = $process.ExitCode
117147 }
118148 finally {
119- if ($hadNativePreference ) {
120- $PSNativeCommandUseErrorActionPreference = $previousNativePreference
121- }
149+ Remove-Item - LiteralPath $stdoutPath , $stderrPath - Force - ErrorAction SilentlyContinue
122150 }
123151
124152 if ($output ) {
@@ -221,7 +249,7 @@ Python $MinMajor.$MinMinor+ was not found.
221249
222250Install Python by running:
223251
224- winget install Python.Python.3.14
252+ winget install Python.Python.3.12
225253
226254Then open a new terminal window and run this installer again.
227255"@
0 commit comments