Prevent an application from being closed by the user through the task manager

Asked

Viewed 2,303 times

5

I have a C# application that cannot be closed by the user. But even if I eliminate all the means to close the application, including by itself, it is still possible to finish the process by the task manager. Can you prevent this? You can remove the application from the task manager?

  • Your question is weird. Do you want to remove or what to prevent you from removing from the task manager? Or what you want is to prevent the program from being shut down in any way?

  • Another issue worth considering, the user who can close the process has administrator permissions?

  • I think it just wants to stop the user from finishing the process, but the process itself can end, as some antivirus work (which run at a blocked access level).

  • Sorry for the confusion in the question, the user has administrator permission and do not want the user to close the application.

  • There is a way, use Hooks.

2 answers

9


Generally that is not possible, especially by a code in your application. The application itself has no control over this.

The most that is possible is not giving privilege to close (TERMINATE) the process when installing the program. But this does not completely solve. Thankfully no software can do this.

The user can prevent the software from running automatically at the next startup and it will definitely kill your program easily. So it’s not worth the effort.

If he knows what he’s doing it’s possible to give the privilege on its own without having to give one boot on the machine. There are specialized software that kills processes that cannot be killed. The Process Explorer from Microsoft can help do this.

Surely there are some possible tricks like capturing the NtTerminateProcess in the kernel or create another program that monitors this main one. But no trick is effective. What’s worse is that you think you’re protected when you’re really not.

Forget this idea.

  • Thanks for your help, I’ll see what I can do about it.

0

The solution I found was to keep checking the processes and if the user opens the task manager I close it. I made a Thread for that purpose.

        public void antiGerenciadorDeTarefas() {
            while (true) {
                Process[] processos = Process.GetProcesses();
                foreach (Process processo in processos) {

                    if (processo.ProcessName.Equals("Taskmgr")) {
                        processo.Kill();
                    }
                }
                Thread.Sleep(1000);
            }

        }
  • 3

    First this does not solve the problem because the person can kill the process in several different ways even can still send by task manager. Then you may even be held responsible for trying to circumvent the workings of the computer that is not yours. I do not recommend doing this if not for technical reasons (this solution brings other problems) for ethical reasons.

  • 1

    It is not unethical depending on the reason, in this case I want to make a block screen the style of lan-house.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.