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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to script scenario where process fails to start on time 1

Status
Not open for further replies.

JustScriptIt

Technical User
Oct 28, 2011
73
US
I'm creating a script that involves stopping and starting a service.

How do I handle a situation where service fails to start on time, say, after 2 minutes?


Code to start service
Code:
do   
  Set colProcesses = GetObject("winmgmts:\\" & strComputer & "\root\cimv2"). _
  ExecQuery("Select * from Win32_Process Where Name='smc.exe'")   
  wscript.sleep 100
loop until (colProcesses.count > 0)
 
Something like this ?
Code:
i = 0
Do
  Set colProcesses = GetObject("winmgmts:\\" & strComputer & "\root\cimv2"). _
  ExecQuery("Select * from Win32_Process Where Name='smc.exe'")
  WScript.Sleep 1000
  i = i + 1
Loop Until colProcesses.Count > 0 Or i >= 120

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top