I have a critical program written in c#. It runs every time the user
log on. But sometimes log-oned user forces my application process to
quit by “End Process” in task manager.
How can I be notified whenever the process is killed by task manager?
I want to keep my process always alive. At least after it is killed, I
want it to be restarted automatically.
Is there any way?
You (ultimately) can't prevent an application from being terminated by
someone with the appropriate rights. A user can normally terminate an app if
they started it but not an app started by another user. Note that you can
write a service to monitor the app and if it goes down, the service can
immediately re-start it. Of course someone can always kill the service
itself but only administrators normally. Depending on the app, you may
therefore want to write it as as a service instead (which sounds like what
you need here). Again, only administrators can (normally) terminate it. If
someone does, they do so at their own risk.