监控SQUID服务是否运行脚本

Set Wshell=WScript.CreateObject("WScript.Shell")
do
dim OK
squid = False
set bag=getobject("winmgmts:\\.\root\cimv2")
set pipe=bag.execquery("select * from win32_process where name='squid.exe'")
For Each id In pipe
squid = True:wscript.quit
Next
If not OK Then
Set ServiceSet = GetObject("winmgmts:").ExecQuery("select * from Win32_Service where Name='Squid' and State='Stopped'")
for each Service in ServiceSet
Service.StartService()
Set objEmail = CreateObject("CDO.Message")
objEmail.From =
[email protected]
objEmail.To =
[email protected]
objEmail.Subject = " Smart Card service down"
objEmail.Textbody = "Smart Card service has restarted."
objEmail.Send
next
End If
wscript.sleep 2000
loop

你可能感兴趣的:(脚本,运行,服务,squid,休闲)