Skip to content

Commit

Permalink
live process stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Nov 21, 2024
1 parent 202ae64 commit 52a27e1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions procDump.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ function Run-Process([string]$fileName, [string]$arguments) {
$processInfo.WorkingDirectory = $PSScriptRoot
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $processInfo

$OutEvent = Register-ObjectEvent -Action {
Write-Host $Event.SourceEventArgs.Data
} -InputObject $process -EventName OutputDataReceived

$ErrEvent = Register-ObjectEvent -Action {
Write-Host $Event.SourceEventArgs.Data
} -InputObject $process -EventName ErrorDataReceived

$process.Start() | Out-Null

$process.BeginOutputReadLine()
$process.BeginErrorReadLine()

return $process
}

Expand All @@ -40,11 +53,7 @@ if (-not (Test-Path $filePath)) {
$toolProcess = Run-Process "dotnet.exe" "tool run ModernUOSchemaGenerator -- ModernUO.sln"
$dumpProcess = Run-Process "$procDumpFolder\procdump.exe" "-accepteula -ma -h $($toolProcess.Id) $procDumpFolder"

$dumpProcess.WaitForExit();

Write-Host $toolProcess.StandardOutput.ReadToEnd();
Write-Host $toolProcess.StandardError.ReadToEnd();

Write-Host $dumpProcess.StandardOutput.ReadToEnd();
Write-Host $dumpProcess.StandardError.ReadToEnd();
while (-not $dumpProcess.HasExited) {
Start-Sleep -Seconds 1
}

0 comments on commit 52a27e1

Please sign in to comment.