Results 1 to 2 of 2

Thread: Read List Items in Windows Event Viewer

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Read List Items in Windows Event Viewer

    I'm currently trying to make a program for optimizing people's computers and I'm having a hard time trying to figure out how to read the events from the Windows Event Viewer. Does anyone have any ideas? Thanks

  2. #2
    Lively Member okosv's Avatar
    Join Date
    Sep 2006
    Posts
    95

    Re: Read List Items in Windows Event Viewer

    You can read events via WMI. For example (from msdn.com)
    VB Code:
    1. ' List Events From a Specific Event Log
    2.  
    3. ' Windows Server 2003 : Yes
    4. ' Windows XP : Yes
    5. ' Windows 2000 : Yes
    6. ' Windows NT 4.0 : Yes
    7. ' Windows 98 : No
    8.  
    9. strComputer = "."
    10. Set objWMIService = GetObject("winmgmts:" _
    11.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    12.  
    13. Set colLoggedEvents = objWMIService.ExecQuery _
    14.     ("Select * from Win32_NTLogEvent Where Logfile = 'Application'")
    15.  
    16. For Each objEvent in colLoggedEvents
    17.     Wscript.Echo "Category: " & objEvent.Category
    18.     Wscript.Echo "Computer Name: " & objEvent.ComputerName
    19.     Wscript.Echo "Event Code: " & objEvent.EventCode
    20.     Wscript.Echo "Message: " & objEvent.Message
    21.     Wscript.Echo "Record Number: " & objEvent.RecordNumber
    22.     Wscript.Echo "Source Name: " & objEvent.SourceName
    23.     Wscript.Echo "Time Written: " & objEvent.TimeWritten
    24.     Wscript.Echo "Event Type: " & objEvent.Type
    25.     Wscript.Echo "User: " & objEvent.User
    26. Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width