can I set the restart/recovery properties for a windows service from code?
I am referencing this answered question...
I see that one can manually configure a service to restart using Services control panel. Is there a way to set these va开发者_运维知识库lues in code, either from the Service itself or, more likely, from the Service Installer?
Use the SERVICE_CONFIG_FAILURE_ACTIONS
option of the ChangeServiceConfig2 function.
I did not specify it in my original question, but I am working in c#./net, and had some trouble getting the calls to win32 just right (I don't have a lot of experience in this area). In the end, I found a nice implementation/explanation, which helped me finally get it right.
Here's the link:
http://netcode.ru/dotnet/?lang=&katID=30&skatID=277&artID=7660
精彩评论