[python-win32] wmi and NT service

walou c.walou at laposte.net
Mon Nov 22 16:11:44 CET 2004


Hello,
While I was crawling python.org I found :

"""c = wmi.WMI()
event_watcher=c.watch_for
(notification_type="Creation",wmi_class="Win32_NTLogEvent",delay_secs=1)

<while service is running>
evt=event_watcher()
<code to examine event, raise flag if detect RAID event>"""

I want to know any changes in Win32_Session in a NT service. So I tried :

...
def SvcDoRun(self):
    import wmi
    c = wmi.WMI()
    event_watcher=c.watch_for(notification_type="Creation",wmi_class="Win32_Session",delay_secs=1)
    evt = event_watcher()
    fh = file('c:\montest.log','w')
    fh.write('coucou')
    fh.close
...

Just pasted in a .py file, it works fine (I tested it by installing IIS FTP Server and opening sessions on it, note that if you want to retest, you have to use an other login)
The entire code of the service comes from another which works fine, I just replace a few lines with the ones I wrote above.
The service don't start anymore ... does somebody see why ?


Klaas




More information about the Python-win32 mailing list