Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Windows service that I build on a build server and then install on multiple remote servers using Sysinternals PSExec and sc create. This was worked well to this point but I now have a need to set the recovery options for the service so the service will restart itself or the machine in the event of a failure.

In a perfect World I would be able to pass some parameters in my sc create command but it doesn't appear that easy.

Can anybody help me?

Thanks, Chris

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

You are correct in that sc won't manipulate these settings. These settings are stored in the "FailureActions" REG_BINARY value, which is mostly opaque in nature. Your best bet would be to set the value as you want it on a test service then export the registry value. You would just import it after you use sc to create the service in your deployment script.

The API to manipulate these settings is ChangeServiceConfig2, and it's conceivable that you could code something to manipulate the values as you desire if you need flexibility.

share|improve this answer
    
Thanks for you response Evan. I'm currently using a batch script that installs the service each time I build. It deletes the existing service using sc delete and then uses sc create to reinstall the service. –  user36540 Jun 24 '11 at 18:22
    
Sorry, my previous comment was cut off. I think I can swing the solution you presented above but it adds a couple degrees of complication. Is it possible to update the binary for my service without deleting it? If I don't delete then the recovery options would remain intact. –  user36540 Jun 24 '11 at 18:24
1  
As long as the service is stopped you can update the binary. There's no need to re-register the service as long as the binary's path and filename remains the same. –  Evan Anderson Jun 24 '11 at 21:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.