gcue Posted January 2, 2009 Share Posted January 2, 2009 i have the following script that checks for an event log but i want it to error out if it doesnt find the log.. ive tried isnotarray($objWMIService) and "if @error" at different spots but i still get "subscript used with non-Array variable" $Query_Clause = "Select * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND Type = 'Information' AND SourceName = 'Altiris Recovery Solution' AND EventCode = 31" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & $asset & "\root\cimv2") ;~ If Not IsArray($objWMIService) Then ;~ Local $aText[3] = ["Dashboard", @TAB & "Status", @TAB & @TAB & "Idle"] ;~ Local $aParts[3] = [200, 175, -1] ;~ $dSTATUS = _GUICtrlStatusBar_Create($dGUI, $aParts, $aText) ;~ MsgBox(0, "Check Recovery Solution", "No successful snapshots have been taken.") ;~ Return ;~ EndIf If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery($Query_Clause) If IsObj($colItems) Then For $objEvent In $colItems $Output = "" $Output &= "Message: " & $objEvent.Message & @CRLF $message = $Output ExitLoop Next EndIf EndIf Link to comment Share on other sites More sharing options...
FireFox Posted January 2, 2009 Share Posted January 2, 2009 @gcue Maybe... Func _ObjGet() $Query_Clause = "Select * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND Type = 'Information' AND SourceName = 'Altiris Recovery Solution' AND EventCode = 31" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & $asset & "\root\cimv2") If $objWMIService = 0 Then SetError(1) Return 0 ElseIf $objWMIService <> '' Then Return 1 EndIf SetError(2) Return 0 EndFunc ;==>_ObjGet If _ObjGet() Then MsgBox(64, "ObjGet", $objWMIService) Else MsgBox(16, "ObjGet", "Error : " & @error) EndIf Cheers, FireFox. Link to comment Share on other sites More sharing options...
gcue Posted January 2, 2009 Author Share Posted January 2, 2009 (edited) actually i figured it out.. it was coming from an array call later.. so i did a if not isarray check which worked! thanks anyway!! Edited January 2, 2009 by gcue Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now