franck34 bqomrvliagmailcom usage serviceexe install serviceexe start serviceexe stop serviceexe remove see output program running python sitepackageswin32libwin32traceutil import win32service import win32serviceutil import win32event import win32evtlogutil import win32traceutil import servicemanager import winerror import time import sys class aservicewin32serviceutilserviceframework _svc_name_ aservice _svc_display_name_ aservice nothing _svc_deps_ eventlog def __init__selfargs win32serviceutilserviceframework__init__selfargs selfhwaitstopwin32eventcreateeventnone 0 0 none selfisalivetrue def svcstopself tell service manager trying stop required selfreportservicestatuswin32serviceservice_stop_pending write message sm optional import servicemanager servicemanagerloginfomsgaservice recieved stop signal set event call win32eventseteventselfhwaitstop selfisalivefalse def svcdorunself import servicemanager write started event event log required win32evtlogutilreporteventself_svc_name_servicemanagerpys_service_started0 servicemanagereventlog_information_typeself_svc_name_ methode 1 wait beeing stopped win32eventwaitforsingleobjectselfhwaitstop win32eventinfinite methode 2 wait beeing stopped selftimeout1000 milliseconds update every second selfisalive wait service stop signal timeout loop rcwin32eventwaitforsingleobjectselfhwaitstop selftimeout print looping write stopped event event log required win32evtlogutilreporteventself_svc_name_servicemanagerpys_service_stopped0 servicemanagereventlog_information_typeself_svc_name_ selfreportservicestatuswin32serviceservice_stopped return __name__ __main__ called without argvs lets run lensysargv 1 try evtsrc_dll ospathabspathservicemanager__file__ servicemanagerpreparetohostsingleaservice servicemanagerinitializeaservice evtsrc_dll servicemanagerstartservicectrldispatcher except win32serviceerror details details0 winerrorerror_failed_service_controller_connect win32serviceutilusage else win32serviceutilhandlecommandlineaservice thu 07 aug 2008 151624 0200 pythonwin32 windows service sample using pyinstaller