Pages

Thursday 23 July 2009

Check Service - VBScript

On Error resume next
Dim StrComputer: strComputer = "."
Dim oservice
Dim oWMIService : Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Dim colServiceList: Set colServiceList = oWMIService.ExecQuery("Select * from Win32_Service where Name='SharedAccess'")


For Each oService in colServiceList


if oService.startmode="Manual" or oService.startmode="Disabled" then
wscript.quit(1)
end if


if oservice.State="Stopped" then
wscript.quit(1)
end if


Next

No comments:

Post a Comment