Hi,
While executing my vbscipt which uses WMI scripts I am occasionally getting "IWbemObjectSink->Indicate failed with error: 0x80041033" errors in application event log.
When searched in net it shows "User has requested an operation while WMI is in the process of shutting down."
What should I do to get rid of this error ?
Please help.
Thanks in advance
Krishna.
Script:============================================
Option Explicit
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Dim StateDataType
Dim StrService
Dim StrComputer
Dim IsServiceAvailable
Dim ObjWMIService , StrQuery , ColListOfServices , ObjService
Dim State 'State Result
'==========================
' Variable Initialization
'===========================
State = ""
StrComputer = "."
StateDataType = 3
StrService = "netlogon"
IsServiceAvailable = False
'===========================
'Initialize WMI query Object
'===========================
Set ObjWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & StrComputer & "\root\cimv2")
If Err.number <> 0 Then
Call ObjMOMAPI.LogScriptEvent("sp.vbs",1001, EVENT_TYPE_ERROR , "WMI Call Failed with Error: " & Err.Description)
Wscript.quit
End If
StrQuery = "Select * from Win32_Service Where Name = '" & StrService & "'"
Set ColListOfServices = ObjWMIService.ExecQuery (StrQuery)
'=============================================================
'Set the value to BAD, if either service not found or not running
'=============================================================
For Each ObjService in ColListOfServices
IsServiceAvailable = True
if ObjService.State = "Running" Then
State = "GOOD"
Else
State = "BAD"
End If
'Only one service will be returned and processed and hence need to exit the loop here
Exit For
Next
if (IsServiceAvailable = False) Then
Call ObjMOMAPI.LogScriptEvent("sp.vbs",1002, EVENT_TYPE_ERROR , "service(Sftlist) not available")
State = "BAD"
End If
Wscript.Echo State
Wscript.quit
================================================
While executing my vbscipt which uses WMI scripts I am occasionally getting "IWbemObjectSink->Indicate failed with error: 0x80041033" errors in application event log.
When searched in net it shows "User has requested an operation while WMI is in the process of shutting down."
What should I do to get rid of this error ?
Please help.
Thanks in advance
Krishna.
Script:============================================
Option Explicit
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Dim StateDataType
Dim StrService
Dim StrComputer
Dim IsServiceAvailable
Dim ObjWMIService , StrQuery , ColListOfServices , ObjService
Dim State 'State Result
'==========================
' Variable Initialization
'===========================
State = ""
StrComputer = "."
StateDataType = 3
StrService = "netlogon"
IsServiceAvailable = False
'===========================
'Initialize WMI query Object
'===========================
Set ObjWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & StrComputer & "\root\cimv2")
If Err.number <> 0 Then
Call ObjMOMAPI.LogScriptEvent("sp.vbs",1001, EVENT_TYPE_ERROR , "WMI Call Failed with Error: " & Err.Description)
Wscript.quit
End If
StrQuery = "Select * from Win32_Service Where Name = '" & StrService & "'"
Set ColListOfServices = ObjWMIService.ExecQuery (StrQuery)
'=============================================================
'Set the value to BAD, if either service not found or not running
'=============================================================
For Each ObjService in ColListOfServices
IsServiceAvailable = True
if ObjService.State = "Running" Then
State = "GOOD"
Else
State = "BAD"
End If
'Only one service will be returned and processed and hence need to exit the loop here
Exit For
Next
if (IsServiceAvailable = False) Then
Call ObjMOMAPI.LogScriptEvent("sp.vbs",1002, EVENT_TYPE_ERROR , "service(Sftlist) not available")
State = "BAD"
End If
Wscript.Echo State
Wscript.quit
================================================