Writing to the windows logs in Python

Is it possible to write to the windows logs in python?


Asked by: Roman777 | Posted: 28-01-2022






Answer 1

Yes, just use Windows Python Extension, as stated here.

import win32evtlogutil
win32evtlogutil.ReportEvent(ApplicationName, EventID, EventCategory,
                EventType, Inserts, Data, SID)

Answered by: Lana194 | Posted: 01-03-2022



Similar questions

writing python script on windows

I am new to python scripts . I have few repetative testing tasks such logging to various IM's ex (OCS,different public messengers) etc . Is it possible to automate these tasks using python . If so from where do I start with ? Working on windows 2003 server . I know the basics of python. want to enhance the skills . Thanks, Tazim


How to check if a file is open for writing on windows in python?

We have a process here at work where an input file is created by SAS. That input file is then read by a legacy application and that legacy application creates results. SAS then reads the results and summarizes them. A non-programmer usually takes care of these actions one by one. So the person just creates the input file. They know when it is done, and then they run the legacy application, and they know when that is d...


Writing python on mac to use on Windows

I've seen from some sources that although you can make an exe or mac equivalent app using py2exe or py2app, you can only make the one your system is. Makes sense when I think about it. But my problem is sometimes I want to write python scripts and send them to my Windows-using friends to test and play with. But Windows doesn't come with python installed, and I don't want to make them have to install Python. ...


python - Writing a CSV on Windows

I wrote this script that works fine on my Mac, but not so well on my Windows machine (where it needs to run). I'm trying to append to a CSV. Snippet: with open('timeclock.csv', 'a') as timeclocklog: timeclockwriter = csv.writer(timeclocklog) timeclockwriter.writerow([now, inorout]) When I try that, I get no lines appended to my CSV. If I change the a to ab


writing python script on windows

I am new to python scripts . I have few repetative testing tasks such logging to various IM's ex (OCS,different public messengers) etc . Is it possible to automate these tasks using python . If so from where do I start with ? Working on windows 2003 server . I know the basics of python. want to enhance the skills . Thanks, Tazim


How to check if a file is open for writing on windows in python?

We have a process here at work where an input file is created by SAS. That input file is then read by a legacy application and that legacy application creates results. SAS then reads the results and summarizes them. A non-programmer usually takes care of these actions one by one. So the person just creates the input file. They know when it is done, and then they run the legacy application, and they know when that is d...


Writing python on mac to use on Windows

I've seen from some sources that although you can make an exe or mac equivalent app using py2exe or py2app, you can only make the one your system is. Makes sense when I think about it. But my problem is sometimes I want to write python scripts and send them to my Windows-using friends to test and play with. But Windows doesn't come with python installed, and I don't want to make them have to install Python. ...


python - Writing a CSV on Windows

I wrote this script that works fine on my Mac, but not so well on my Windows machine (where it needs to run). I'm trying to append to a CSV. Snippet: with open('timeclock.csv', 'a') as timeclocklog: timeclockwriter = csv.writer(timeclocklog) timeclockwriter.writerow([now, inorout]) When I try that, I get no lines appended to my CSV. If I change the a to ab


XML writing tools for Python

I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of? This is similar to what I'm actually doing: import xml.etree.ElementTree as ET root = ET.Element('html') head = ET.SubElement(root,'head') script = ET.SubElement(head,'script') script.set('type','text/javascript') script.text = "var a = 'I lo...


Writing unit tests in Django / Python

I've not used Unit Tests before other than a quick introduction in a Uni course. I'm currently writing an application though and would like to teach myself TDD in the process. The problem is, I've no idea what to test or really how. I'm writing a Django application, and so far have only created the models (and customised the admin application). This is how I've written the skeletons of my tests so far:


is there COMMIT analog in python for writing into a file?

I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that true? What if the system crashes when the main process is not finished yet? Is there a way to do kind of commit once every... say -- 10 minutes (and I call this commit myself -- ...


Writing binary data to a socket (or file) with Python

Let's say I have a socket connection, and the 3rd party listener on the other side expects to see data flowing in a very structured manner. For example, it looks for an unsigned byte that denotes a type of message being sent, followed by an unsigned integer that denotes the length of message, then another unsigned byte which is really a bit field with some flags set or unset and etc... How would I do this in python...


Writing a binary buffer to a file in python

I have some python code that: Takes a BLOB from a database which is compressed. Calls an uncompression routine in C that uncompresses the data. Writes the uncompressed data to a file. It uses ctypes to call the C routine, which is in a shared library. This mostly works, except for the ac...


Writing a website in Python

I'm pretty proficient in PHP, but want to try something new. I'm also know a bit of Python, enough to do the basics of the basics, but haven't used in a web design type situation. I've just written this, which works: #!/usr/bin/python def main(): print "Content-type: text/html" print print "<html><head>" print "<title>Hello World from Python</title>" ...


Writing python client for SOAP with suds

I want to convert a perl SOAP client into a python SOAP client. The perl client is initialized like $url = 'https://host:port/cgi-devel/Service.cgi'; $uri = 'https://host/Service'; my $soap = SOAP::Lite -> uri($uri) -> proxy($url); I tried to replicate this in python 2.4.2 with suds 0.3.6 doing from suds.client import Client url="https://host:port/cgi-devel...


Writing Sudoku Solver wih Python

Here is my Sudoku Solver written in python language, When I run this program there seems to be a problem with in Update function and Solve function. No matter how much time I look over and move the codes around, I seem to have no luck Can anyone Help me? import copy def display (A): if A: for i in range (9): for j in range (9): if type (A[i][j...


Writing an XML file using python

I have to write an xml file using python standard modules (not using elementtree, lxml etc) The metadata is a SAML identity provider metadata and is of the form - <?xml version="1.0"?> <EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" entityID="http://wsa.saas.com"> <IDPS...


c# - Writing crawler that stay logged in with any server

I am writing a crawler. Once after the crawler logs into a website I want to make the crawler to "stay-always-logged-in". How can I do that? Is a client (like browser, crawler etc.,) make a server to obey this rule? This scenario could occur when the server allows limited logins in day.






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top