djfistic Posted August 16, 2013 Posted August 16, 2013 hi all, I need to get on some computer and servers all error and warning logs. But I have a problem with the function Eventlog_read on the text return on the fields "description" . see the example bellow : When i watch logs with eventvwr.msc "event viewer on Windows" in the field description on one error log ,I have the text: "L'imprimante Print01 sur srv01 (à partir de PC201) dans la session 1 a été supprimée. Pour plus d’informations, consultez le centre Aide et support à l’adresse http://go.microsoft.com/fwlink/events.asp." but when i use the function "eventlog_read" the return text on the field description is not whole: it's only the text "Print01 sur srv01 (à partir de pc201) dans la session 1" It's strange because on some other error log the message is not cut. see the code bellow: thanks in advance expandcollapse popup#Include <EventLog.au3> #Include <EventLog.au3> #Include <Array.au3> $cpt=0 $hEventLog = _EventLog__Open("", "system") $eventArray1 = _EventLog__Read($hEventLog, True, False) _ArrayDisplay ($eventArray1) ; the highest number $hEventLog = _EventLog__Close($hEventLog) $hEventLog = _EventLog__Open("", "system") $eventArray2 = _EventLog__Read($hEventLog, True, True) _ArrayDisplay ($eventArray2) ; the lowest number $hEventLog = _EventLog__Close($hEventLog) $hEventLog = _EventLog__Open("", "system") Dim $arraymemo[1] Dim $arrayfinal[$eventArray1[1]][7] $arrayfinal[0][0]="Date" $arrayfinal[0][1]="Heure" $arrayfinal[0][2]="Type" $arrayfinal[0][3]="Source Prob" $arrayfinal[0][4]="Nom Pc" $arrayfinal[0][5]="Message" $arrayfinal[0][6]="Nb x Erreur" $cptTot = $eventArray1[1] $cptDeb = $eventArray2[1] $datejour=@MON&"/"&@MDAY&"/"&@YEAR;date of day $datejourprec=@MON&"/"&@MDAY-1&"/"&@YEAR;yesterday $i=$cptTot Do $loopArray = _EventLog__Read($hEventLog, False, False, $i) If $loopArray[2]=$datejour And $loopArray[8]="error" Or $loopArray[8]="warning" Then $messlog=_ArraySearch($arraymemo,$loopArray[13],0, 0, 0, 1) ; search on array memo if log message exist If $messlog = -1 Then ;if log not exist $cpt=$cpt+1 _ArrayAdd($arraymemo,$loopArray[13]); add log message on array memo $arrayfinal[$cpt][0]=$loopArray[2]; Date of log $arrayfinal[$cpt][1]=$loopArray[3] ; Ti me of log $arrayfinal[$cpt][2]=$loopArray[8] ; type of log $arrayfinal[$cpt][3]=$loopArray[10] ; source $arrayfinal[$cpt][4]=$loopArray[11] ; Computer $arrayfinal[$cpt][5]=$loopArray[13] ; Description $arrayfinal[$cpt][6]=1 Else $messlog=_ArraySearch($arraymemo,$loopArray[13]) If Not @error Then $arrayfinal[$messlog][6]=$arrayfinal[$messlog][6]+1 EndIf EndIf $i=$i-1 Until $loopArray[2]=$datejourprec Or $i=$cptDeb ; quit the loop when the date is yesterday or on the end of log $hEventLog = _EventLog__Close($hEventLog) _ArrayDisplay ($arrayfinal)
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