Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a Timeout when checking a Service status 1

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
0
0
GB
Hi

I have a script we run twice a day which (amongst many other things) checks the status of a Windows Service on various hosts. In short with "Set colRunningServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name = '" & strServiceName & "'")" and "strServiceStatus = objService.State".

The trouble is, if a server is, let's say, in a bit of a state, this check just sits there doing nothing until we reboot the server and restart the script. What I need is for it to give up checking the service after a certain amount of time.

Is possible?

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
 
Thanks, Geates, but I don't think I've been clear. The issue is that sometimes the query of the service isn't receiving a response at all. So testing, as you are suggesting, if the service is in a stopped state will still fail because the server is unresponsive to such querying.

The specific server I've got a problem with can have a RDP session started to it, but when you log on the dialog just sits at "Loading your personal settings".

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top