vbscript - How to write a VBS Script to check a website and then stop and start a windows service -
i need write vbs script check website text : "service unavailable" , "error in /"
when finds need restart windows service "world wide publishing service"
where start?
any appreciated!
cheers!
andy
you can check on web site using msxml2.xmlhttp object (ie same object internet explorer uses fire ajax requests) , checking status code (200 status ok, 404 page not found etc)
dim http: set http = createobject("msxml2.xmlhttp") http.open "get", "http://site.com?param=value", false http.send if not http.status = 200 ' not right, start service end if
as far starting service concerned, this page has quite few examples of working services, of how start 1 (copied verbatim, not tested):
strcomputer = "." set objwmiservice = getobject("winmgmts:" _ & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2") set colservicelist = objwmiservice.execquery _ ("select * win32_service name='netdde'") each objservice in colservicelist errreturn = objservice.startservice() next wscript.sleep 20000 set colservicelist = objwmiservice.execquery("associators of " _ & "{win32_service.name='netdde'} " _ & "assocclass=win32_dependentservice " & "role=dependent" ) each objservice in colservicelist objservice.startservice() next
if service want start iis, perhaps dispense http request , instead directly detect whether iis service running or not
Comments
Post a Comment