2
votes

I am trying to read out the windows event log using pywin32:

machineAdress = None
eventType = "Application"

log_handle = win32evtlog.OpenEventLog(machineAdress, eventType)
flags = win32evtlog.EVENTLOG_BACKWARDS_READ | win32evtlog.EVENTLOG_SEQUENTIAL_READ
events = win32evtlog.ReadEventLog(log_handle, flags, 0)

Unfortunately, win32evtlog.ReadEventLog fails with the following error:

OverflowError: days=1757830483; must have magnitude <= 999999999
The above exception was the direct cause of the following exception:
SystemError: <built-in function ReadEventLog> returned a result with an error set

According to the doc:

machineAdress is a Windows host (e.g. "localhost") and eventType is the name of the source of the Windows event logs (e.g. "System", "Application", ...). The error is the same in all cases, only the number of days=... changes.

I'm using Python 3.7 on Windows (64 bit). Thanks in advance!

1
What are machineAdress and eventType (post your full code)? Can you post the full traceback (and the line that generates the error - although it seems it's the last posted one)? Please check [SO]: How to create a Minimal, Complete, and Verifiable example (mcve). Also did you check - CristiFati
machineAdress could be one of ten remote Windows hosts (is a multi-thread app) and eventType one the three Windows possibilities (System, Application..). The error is the same in all cases and only show that trace. Of course, the error is in the ReadEventLog line. - el_apeiron

1 Answers

0
votes

I got the same error. Installing pypiwin32 instead of pywin32 solved the problem for me.

  • If you installed pywin32 using an executable installer:
    Deinstall pywin32 with the Windows option Add or remove programs.

  • If you installed pywin32 via pip install pywin32:
    Deinstall pywin32 via pip uninstall pywin32.

Now run pip install pypiwin32. Worked for me with Windows 10, Python 3.7.0 (both 64 bit) and pypiwin32 v223.