I am trying to start a service in Powershell. If the service does not start within a specified time limit, the attempt to start should be killed, otherwise it should carry on as usual. How do I incorporate a timeout?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Implementing a timeout is a really simple thing to do using background jobs:
This block of code will timeout after 15 seconds, but it should get you started. Basically:
– Track the time
– Start a job
– Wait for it to be no longer running (it could have failed, so don’t just wait for completed)
– Receive Results while you wait
– Timeout if you’ve been waiting too long
Hope this Helps