Menu

#676 win32evtlog.OpenEventLog cannot open log under "Applications and Services Logs"

v1.0 (example)
open
nobody
5
2014-08-15
2014-08-13
Florian
No

I tried a lot of different ways to open one of the log files listed under "Applications and Services Logs" in the Eventlog of Windows 7/2008 R2.
Accessing these logs always resulted in an opened "Application" log which has in my case 9635 entries.

File:
%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-TaskScheduler%4Operational.evtx

Example Code:
hand = win32evtlog.OpenEventLog(None,"Microsoft-Windows-TaskScheduler/Operational")
print win32evtlog.GetNumberOfEventLogRecords(hand)
9635

Discussion

  • Roger Upole

    Roger Upole - 2014-08-14

    You can access the Application and Services logs using the newer Evt* functions introduced with Vista.

     
  • Florian

    Florian - 2014-08-14

    When I try this the Python process crashes.

    I use the current Python 2.7.7 32bit on Windows 7 x64.
    Pywin32 build 219
    Running the script with Administrator rights

    Code:
    logtype = "Microsoft-Windows-Windows Defender/Operational"
    hand = win32evtlog.EvtOpenLog(logtype, 1, None)
    total = win32evtlog.GetNumberOfEventLogRecords(hand)

     
  • Roger Upole

    Roger Upole - 2014-08-15

    Handles aren't portable between the older event log functions and the newer Evt* functions. To get the number of event in the log, try
    win32evtlog.EvtGetLogInfo(h, win32evtlog.EvtLogNumberOfLogRecords)

     
  • Florian

    Florian - 2014-08-15

    Ahh - thank you. Now I see.
    I cannot close this ticket but I consider it closed.

     

    Last edit: Florian 2014-08-15
  • Florian

    Florian - 2014-08-15

    No wait.
    Running this on Windows 2003 completely crashes the python process. I cant handle this with a try catch statement:

    hand = win32evtlog.EvtOpenLog(logtype, 1, None)

     
MongoDB Logo MongoDB