Prevent C# app from process kill

后端 未结 9 1606
我寻月下人不归
我寻月下人不归 2020-11-29 11:39

How can I protect my C# app from someone killing its process via taskman or programmatically?

Here is my scenario:

App A is an MFC app developed by another t

相关标签:
9条回答
  • 2020-11-29 12:05

    You can't - as long as the user has the right to call TerminateProcess on your program, you can't prevent End Process from killing you immediately in task manager. Raymond Chen posted on this some time ago: The arms race between programs and users

    0 讨论(0)
  • 2020-11-29 12:12

    As far as i know you can't, and even if you could you really shouldn't. imagine how annoying it would be if you couldn't force kill an application.

    If its important that your application keep running you could always create a windows service that "pings" the application to ensure it is running (you could use named pipes, sockets, pid files... whatever). if the service detects that the process has died then it can just restart it. this is probably your best bet.

    0 讨论(0)
  • 2020-11-29 12:13

    You really, really, really don't want to do this. It makes users very angry!! However, if it is supposed to be a service, run it as a service account and don't give admin rights to users.

    0 讨论(0)
提交回复
热议问题