Cesar Maiorino
Cesar Maiorino

Reputation: 563

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 values in code, either from the Service itself or, more likely, from the Service Installer?

Upvotes: 1

Views: 240

Answers (2)

Cesar Maiorino
Cesar Maiorino

Reputation: 563

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

Upvotes: 2

Remy Lebeau
Remy Lebeau

Reputation: 595782

Use the SERVICE_CONFIG_FAILURE_ACTIONS option of the ChangeServiceConfig2 function.

Upvotes: 2

Related Questions