Make a service monitor and restart process
i'm making an app that needs to be up and running at all times. (24/7) I'm not very expirienced with services, but I read on the internet that services can be made uncolasble by setting their "onclose" property to false.
开发者_运维问答I have got the service monitoring my app, and the service can't be closed directly from the task manager services window... but, when I click "go to process" task manager leads me to the process the service spawned. From there I can close the process and instantly close the service. Since I don't have much expirience with services i'm wondering, is this behavior normal? If not, how to make the service unstopable?
It sounds like you need something like Slife Teams and then use Windows security to prevent them killing the client app.
Edit If you are using Windows 7 or Windows Server 2008 R2 maybe you can use AppLocker?
Edit 2 Getting back to answering the original question, one way would be to create your monitoring app so that there are two processes running, both monitoring, that know about each other.
Run the two processes, each with an open handle to the other process. When one process is detected as being killed the other process immediately restarts it, and vice-versa.
You will need to handle the normal system shutdown messages.
Or... have a read of this article: Process Invincibility
精彩评论