Running WMI within a Windows service

cameron.mccloud at gmail.com cameron.mccloud at gmail.com
Tue Jun 21 10:58:55 EDT 2005


Hi,

When trying to import the WMI module in a Python Windows Service, I get
the following:

    dynamic module does not define init function (initwmi)

The WMI version is 0.6. Python 2.4 on Win32, Python Win32 extensions
version 203

Code below,

Cam.

    def SvcDoRun(self):

        import servicemanager
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ''))
        print "Running..."

        try:
            import wmi
            print "module imported"
        except Exception, e:
            print "exception: " + str(e)

        print "Stopped."
        self.ReportServiceStatus(win32service.SERVICE_STOPPED)
        servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STOPPED,
                (self._svc_name_, "EventMonSvc stopping..." )
                )




More information about the Python-list mailing list