简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM