[python-win32] Python 3 - Windows Service

David Hautbois david.hautbois at free.fr
Fri May 13 10:02:26 EDT 2016


Hi

I received your empty message :)

pywintypes34.dll was missing for pythonservice.exe.
I copied the file in the same folder.
It works !

I was using the powershell console, that does not display the error 
message about the missing file.
cmd does.

Now, I'm trying to build the binary exe file with pyinstaller.
I get :
C:\temp>dist\sample-pyinstaller.exe install
Redirecting output to win32trace remote collector
Failed to execute script sample-pyinstaller

But this is another issue.....

David.



Le 13/05/2016 15:46, Bob Gailer a écrit :
>
>
> On May 13, 2016 6:38 AM, "David Hautbois" <david.hautbois at free.fr 
> <mailto:david.hautbois at free.fr>> wrote:
> >
> > Hi
> >
> > I passed all this week to get a Python Windows Service running.
> > But, I failed....
> >
> > I tried Windows 2003 and Windows 2012 R2.
> > I installed python 3.4.4 x86
> >
> > I installed pypiwin32 with pip :
> > pip install pyinstaller
> >
> > I tried many sample scripts found on Google.
> > I finally found sample scripts in 
> C:\Python34\Lib\site-packages\win32\Demos\service
> >
> > I modified the servicesEvents.py script and simplified it :
> > ________________________________________________________________________
> > import win32serviceutil, win32service
> > import win32event, win32api
> > import servicemanager
> > import time
> >
> > import win32gui, win32gui_struct, win32con
> >
> > class EventDemoService(win32serviceutil.ServiceFramework):
> >     _svc_name_ = "PyServiceEventDemo"
> >     _svc_display_name_ = "Python Service Event Demo"
> >     _svc_description_ = "Demonstrates a Python service which takes 
> advantage of the extra notifications"
> >
> >     def __init__(self, args):
> >         win32serviceutil.ServiceFramework.__init__(self, args)
> >         self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
> >         self.running = True
> >
> >     def SvcStop(self):
> > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
> >         win32event.SetEvent(self.hWaitStop)
> >         self.running = False
> >
> >     def SvcDoRun(self):
> > self.ReportServiceStatus(win32service.SERVICE_RUNNING)
> >         while self.running:
> >             servicemanager.LogInfoMsg("aservice - is alive and well")
> >             time.sleep(3)
> >
> > def ctrlHandler(ctrlType):
> >     return True
> >
> > if __name__=='__main__':
> >     win32api.SetConsoleCtrlHandler(ctrlHandler, True)
> >     win32serviceutil.HandleCommandLine(EventDemoService)
> > ________________________________________________________________________
> >
> > I get a 2186 error when starting it with cmd : net start 
> PyServiceEventDemo
> > I get a 1053 error when starting it from the services manager.
> We need to see the exact error messages and their contexts. Post as 
> text since this list does not take attachments.
> > I get these errors with this sample and others found from a Google 
> search.
> >
> > What is the status of Python3, pywin32 and Windows services ?
> > Can I enabled some trace to understand the problem ?
> > Could someone give me a working sample ?
> > Could someone point me to some interesting links ?
> >
> > Thanks for your help !
> >
> > David.
> > _______________________________________________
> > python-win32 mailing list
> > python-win32 at python.org <mailto:python-win32 at python.org>
> > https://mail.python.org/mailman/listinfo/python-win32
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20160513/375f410e/attachment-0001.html>


More information about the python-win32 mailing list