I have the following PowerShell 5 program:
$job = Start-Job -ScriptBlock {timeout.exe 10 /NOBREAK}
Wait-Job $job
When I run it, it terminates immediately with the following output:
Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- 1 Job1 BackgroundJob Completed True localhost timeout.exe 10 /NOBREAK
and timeout.exe
does not appear in Task Manager.
Why does it not wait 10 seconds before terminating? When I invoke timeout.exe 10 /NOBREAK
outside a job, it does wait 10 seconds, as does invoking Start-Sleep 10
in a job.
I am not looking for a different way to solve the same problem (sleeping), but specifically for an answer to why this program behaves the way it does.