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

Check Sevice Status 4

Status
Not open for further replies.

grabrail

Technical User
Aug 15, 2001
269
GB
Hi

I have a script that goes away and checks free space on drives of a list of servers.

I need to add functionality to this script to query the status of specific services (started, stopped)

For example I need to check if the IIS services is running or not.

Can anybody tell me if this is possible, and if so how.

Cheers
 
this may be another posibility. you limit what you want returned "DisplayName" and "Status" and you only query those services you want only once on the PC.


ArrComputer = Array(".")
ArrServices = Array("Alerter", "DHCP Client", "DNS Client")
i = 0

For Each strComputer In ArrComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
For Each Service In ArrServices
If i > 0 Then
str = str & " or DisplayName = '" & Service & "'"
Else
str = "DisplayName = '" & Service & "'"
i = i + 1
End If
Next
Set colItems = objWMIService.ExecQuery("Select DisplayName, State from Win32_Service where " & str)
For Each objItem in colItems
Wscript.echo "DisplayName: " & objItem.DisplayName
Wscript.echo "State: " & objItem.State & VbCrLf
Next
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top