C # command line

how can i catch the taskkill command to prevent this?

+4
source share
2 answers

You cannot prevent your process. The only way to keep the program in life is to have a second Watchdog application that constantly integrates this process to ensure its operation.

So, you have two Applications; AppA (Main) and AppB (Watchdog).

AppA checks to see if AppB is AppB . If not, AppA launches AppB .

AppB checks if AppA is AppA . If not, AppB launches AppA .

But this is usually a design for a malicious process, so I hope you are not doing anything unpleasant.

In the message queue, you can see the following events when you click End Process :

WM_CLOSE // UI Application

CTRL_CLOSE_EVENT // Console Application

But if your application does not close in a timely manner, then the kill command will be sent, which is impossible to capture.

+10
source

I am sure that this is not possible, otherwise one application may stop windows from closing. Even when the process freezes, it ultimately kills it in the task manager. If it were possible, malicious software, etc., would probably use this day - not only would they be able to control various parts of your PC, they would make sure that you could never get it back.

+1
source

All Articles