[python-win32] Python Windows Service and registering for preshutdown?

Lincoln Yeoh lyeoh at pop.jaring.my
Tue Feb 7 07:18:09 CET 2012


Hi,

Is it easy to create a python windows service that registers for the 
preshutdown event[1]?

Basically I would like a window service that will help shutdown .Net 
(and possibly other) services in the right order.

Because:
http://connect.microsoft.com/VisualStudio/feedback/details/641737/add-windows-service-preshutdown
"A Windows service in C# cannot be registered to preshutdown 
notifications. It is possible in C++ but not in C# with the current 
.net framework"

http://support.microsoft.com/kb/203878

"When a service is dependendent on other services, the Service 
Control Manager (SCM) will automatically start the dependencies 
before starting the dependent service itself. However, during system 
shutdown, the SCM does not take dependencies into consideration when 
stopping services. It simply enumerates the list of running services 
and sends a SERVICE_CONTROL_SHUTDOWN command to all of them. Thus, a 
service may stop responding or fail because another service it 
depends upon has already stopped."

(yeah weird right?)

And, since I'm a crappy and lazy programmer I think it'll be easier 
for me to write such a thing in Python than C++, reasonably quickly, 
with the features I want and with not too many bugs.

Regards,

Link.

[1] http://msdn.microsoft.com/en-us/magazine/cc164252.aspx#S2



More information about the python-win32 mailing list