gata
2006-06-30 07:01:01 UTC
I test for getting service instance with following script.
1st Get() is success, but 2nd Get() is error.
Why?
-----------------------------------------------------------------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")
' 1. get instance using Name of Service
strWQL = "Win32_Service.Name='Spooler'"
Set objService = objWMIService.Get(strWQL)
If Not objService Is Nothing Then
WScript.Echo objService.State & vbTab & " : " & objService.Name & " [" &
objService.DisplayName & "]"
End If
' 2. get instance using Display Name of Service
strWQL = "Win32_Service.DisplayName='Print Spooler'"
Set objService = objWMIService.Get(strWQL)
If Not objService Is Nothing Then
WScript.Echo objService.State & vbTab & " : " & objService.Name & " [" &
objService.DisplayName & "]"
End If
WScript.Qui
-----------------------------------------------------------------------------------------------
1st Get() is success, but 2nd Get() is error.
Why?
-----------------------------------------------------------------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")
' 1. get instance using Name of Service
strWQL = "Win32_Service.Name='Spooler'"
Set objService = objWMIService.Get(strWQL)
If Not objService Is Nothing Then
WScript.Echo objService.State & vbTab & " : " & objService.Name & " [" &
objService.DisplayName & "]"
End If
' 2. get instance using Display Name of Service
strWQL = "Win32_Service.DisplayName='Print Spooler'"
Set objService = objWMIService.Get(strWQL)
If Not objService Is Nothing Then
WScript.Echo objService.State & vbTab & " : " & objService.Name & " [" &
objService.DisplayName & "]"
End If
WScript.Qui
-----------------------------------------------------------------------------------------------