[python-win32] How to invoke Python program from Windows service?

Mark Hammond skippy.hammond at gmail.com
Fri Jun 22 03:41:08 CEST 2012


On 22/06/2012 6:25 AM, Funke, Matt wrote:
> I’m relatively new to the world of Windows programming, but I have a
> Python program I’d like to run every once in a while from a Windows
> service.  I’ve gotten the service itself to run as it’s supposed to, but
> attempts to run the program with a DOS command (using ProcessStartInfo)
> are unsuccessful.  Does anyone have any advice?

Note you can write the service directly in Python using pywin32.  If you 
want to write the service using some other technology and just spawn 
Python, then I'd suggest using just CreateProcess.  But with both 
CreateProcess and ProcessStartInfo, you need a way to redirect output 
from the Python process so you can get diagnostics from the output - 
just telling us it is "unsuccessful" doesn't help us tell you what 
problem you have.

Mark

>
> (This program, written in Python 2.7.3, depends heavily on other
> libraries – reportlab, SQLAlchemy, and a bunch of others.  It works now,
> and I’d rather not rewrite it if I don’t have to.)
>
> *Matt Funke***
>
> Programmer/Analyst
>
> Vishay Precision Group, Inc.
>
> 951 Wendell Blvd
>
> Wendell, NC 27591 USA
>
> Office: 919-374-5553
>
> Mobile: 919-628-9261
>
> Fax: 919-374-5248
>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>



More information about the python-win32 mailing list