How can you set a time limit for a PowerShell script to run for?

前端 未结 6 994
再見小時候
再見小時候 2021-01-05 15:36

I want to set a time limit on a PowerShell (v2) script so it forcibly exits after that time limit has expired.

I see in PHP they have commands like set_time_limit an

6条回答
  •  清歌不尽
    2021-01-05 16:14

    Something like this should work too...

    $job = Start-Job -Name "Job1" -ScriptBlock {Do {"Something"} Until ($False)}
    Start-Sleep -s 10
    Stop-Job $job
    

提交回复
热议问题