Search Results

Search found 1 results on 1 pages for 'calrain'.

Page 1/1 | 1 

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

    - by calrain
    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 and max_execution_time where you can limit how long the script and even a function can execute for. With my script, a do/while loop that is looking at the time isn't appropriate as I am calling an external code library that can just hang for a long time. I want to limit a block of code and only allow it to run for x seconds, after which I will terminate that code block and return a response to the user that the script timed out. I have looked at background jobs but they operate in a different thread so won't have kill rights over the parent thread. Has anyone dealt with this or have a solution? Thanks!

    Read the article

1