, so there is nothing wrong with the script.
the below works fine, i.e. on my remote machine imapiservice isnt running and i get a prompt on the screen.
arrServers = Array("braits705c")
Set dicServices = Wscript.CreateObject("Scripting.Dictionary")
dicServices.Add "client32", "1"
dicServices.Add "workstation", "1"
dicServices.Add "server", "1"
dicServices.Add "imapiservice", "1"
For Each aServer In arrServers
Call listService(aServer)
Next
sub listService (strPCname)
dim objComputer,service
Set objComputer = GetObject("WinNT://" & strPCname)
objComputer.filter = Array("service")
for each service in objComputer
If service.status = 1 Then
'msgbox ""
'msgbox service.name
If dicServices.Exists(LCase(service.name)) Then
Wscript.Echo strPCName & " " & service.name
End If
End If
next
Set objComputer = Nothing
end sub
'you could improve the script by changing the value of each dictionary object to what status you wnat to check against like
dicServices.Add "client32", "1"
dicServices.Add "workstation", "4"
dicServices.Add "server", "1"
and change the for each loop to
for each service in objComputer
If dicServices.Exists(LCase(service.name)) Then
If service.status = dicServices.Item(LCase(service.name)) Then
Wscript.Echo strPCName & " " & service.name
End If
End If
next
'that way you can specify different status criteria for each service you want to check for.
'did you notice my use of the Msgbox's? this helped in debugging what was going on, i.e. once the msgbox's came up in the script i knew the status = 1 check was working and that the 'problem' (not that there was one) was because the service.name didnt exist in the dicservices dictionary object, once i had include a service which i knew was stopped it worked ok (i.e. imapiservice)