/build/static/layout/Breadcrumb_cap_w.png

Add multiple value in a column

Hi,

I am using the below script to find a specific service which was not running.


strComputer = "."
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM Win32_Service where state !='Running' and DisplayName = 'Oracleservicetest'")
For Each objSWbemObject In colSWbemObjectSet
WScript.Echo "Display Name: " & objSWbemObject.DisplayName & vbCrLf & _
" State: " & objSWbemObject.State & vbCrLf & _
" Start Mode: " & objSWbemObject.StartMode & vbCrLf
Next



I would like to see some other service also like netlogon.

I tried this but not working.
SELECT * FROM Win32_Service where state !='Running' and DisplayName in ('Oracleservicetest' ,'netlogon')

Please help.

0 Comments   [ + ] Show comments

Answers (3)

Posted by: captain_planet 14 years ago
Black Belt
0
I guess you could loop through an array of service display names (like below) or just use 'OR' clauses in your SQL like this:

Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM Win32_Service WHERE state !='Running' AND (DisplayName = 'Oracleservicetest' OR DisplayName = 'netlogon')")

Dim serviceArray(1)
serviceArray(0) = "Oracleservicetest"
serviceArray(1) = "netlogon"

Dim i : i = 0
Dim strComputer : strComputer = "."
Dim serviceDisplayName : serviceDisplayName = ""

Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

For Each serviceDisplayName In serviceArray

Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM Win32_Service WHERE state !='Running' AND DisplayName = '" & serviceDisplayName & "'")
For Each objSWbemObject In colSWbemObjectSet
WScript.Echo "Display Name: " & objSWbemObject.DisplayName & vbCrLf & _
" State: " & objSWbemObject.State & vbCrLf & _
" Start Mode: " & objSWbemObject.StartMode & vbCrLf
Next
Set colSWbemObjectSet = Nothing
Next

Set objSWbemServices = Nothing
Posted by: nokiak810 14 years ago
Senior Yellow Belt
0
Hi Captain,

Thanks for the scripts. It works fine like a charm.

Actually my request is to send mail to my mail id if any of the services fails to run or it is not running. Please guide me in this.
Posted by: anonymous_9363 14 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ