What is the easiest way to get just Errors in System and the Application
event logs and dump them to a text file to be read later?

Script, utility?

Thanks

Re: Best way to get event logs. by joseomjr

joseomjr
Thu Dec 14 23:52:45 CST 2006

see the win32_ntlogevent WMI class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_ntlogevent.asp

Also see examples from Microsofts website
http://www.microsoft.com/technet/scriptcenter/scripts/logs/eventlog/default.mspx
Purtech (remove) wrote:
> What is the easiest way to get just Errors in System and the Application
> event logs and dump them to a text file to be read later?
>
> Script, utility?
>
> Thanks


Re: Best way to get event logs. by Fosco

Fosco
Fri Dec 15 00:44:48 CST 2006

Purtech:
> What is the easiest way to get just Errors in System and the Application
> event logs and dump them to a text file to be read later?
>
> Script, utility?

http://www.eventlogxp.com/


--
Fosco

Re: Best way to get event logs. by Tylerb

Tylerb
Fri Dec 15 21:18:42 CST 2006


Hi,
I wrote you simple script to get you started...

'start of script

option explicit
on error resume next
dim strcomputer, objwmiservice, colLoggedEvents, objEvent
dim objFSO, objfile

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{(Security)}\\" & strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
("Select * From Win32_NTLogEvent Where EventType = 1")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile _
("c:\errorevents.txt", 8, True)
objfile.writeline " Error Event Log @ " & NOW
objfile.writeline
For Each objEvent in colLoggedEvents
objfile.writeline "Category: " & objEvent.Category
objfile.writeline "Event Code: " & objEvent.EventCode
objfile.writeline "Message: " & objEvent.Message
objfile.writeline "Record Number: " & objEvent.RecordNumber
objfile.writeline "Source Name: " & objEvent.SourceName
objfile.writeline "Time Written: " & objEvent.TimeWritten
objfile.writeline "Event Type: " & objEvent.Type
Next

objfile.close

wscript.echo "All done"

'end of script

Cheers,
Tyler