Merge pull request #3803 from mitchellh/issue-3729
guests/windows: change elevated shell output to better get output
This commit is contained in:
commit
5899227126
|
@ -71,25 +71,23 @@ while ( (!($registered_task.state -eq 4)) -and ($sec -lt $timeout) ) {
|
||||||
$sec++
|
$sec++
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read the entire file, but only write out new lines we haven't seen before
|
function SlurpOutput($out_file, $cur_line) {
|
||||||
$numLinesRead = 0
|
|
||||||
do {
|
|
||||||
Start-Sleep -m 100
|
|
||||||
|
|
||||||
if (Test-Path $out_file) {
|
if (Test-Path $out_file) {
|
||||||
$text = (get-content $out_file)
|
get-content $out_file | select -skip $cur_line | ForEach {
|
||||||
$numLines = ($text | Measure-Object -line).lines
|
$cur_line += 1
|
||||||
$numLinesToRead = $numLines - $numLinesRead
|
|
||||||
|
|
||||||
if ($numLinesToRead -gt 0) {
|
|
||||||
$text | select -first $numLinesToRead -skip $numLinesRead | ForEach {
|
|
||||||
Write-Host "$_"
|
Write-Host "$_"
|
||||||
}
|
}
|
||||||
$numLinesRead += $numLinesToRead
|
|
||||||
}
|
}
|
||||||
|
return $cur_line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cur_line = 0
|
||||||
|
do {
|
||||||
|
Start-Sleep -m 100
|
||||||
|
$cur_line = SlurpOutput $out_file $cur_line
|
||||||
} while (!($registered_task.state -eq 3))
|
} while (!($registered_task.state -eq 3))
|
||||||
|
|
||||||
$exit_code = $registered_task.LastTaskResult
|
$exit_code = $registered_task.LastTaskResult
|
||||||
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($schedule) | Out-Null
|
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($schedule) | Out-Null
|
||||||
|
|
||||||
exit $exit_code
|
exit $exit_code
|
||||||
|
|
Loading…
Reference in New Issue