Add multiple value in a column
Hi,
I am using the below script to find a specific service which was not running.
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.
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)
Please log in to answer
Posted by:
captain_planet
14 years ago
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
Posted by:
anonymous_9363
14 years ago
Please guide me in thishttp://www.lmgtfy.com/?q=vbscript+xp+send+mail
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.