Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
i am a .net programmer, i need a soln, am creating a windows application, i want to prevent my application by killing application process from the task manager. Like when we try to kill a windows process, anyone have any idea plz comment me
Posted 14-Jan-13 7:25am
Comments
wolfcoder75 at 14-Jan-13 15:06pm
   
I would recomend from reading the above posts, to maybe have a scheduled task or something of the sort that looks to see if the process is not running then start it.
 
Meaning, sure they can close it but you can just open it back up again.
 
Depending on the need for this may or may not be useful. (repost for options to original question)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
It's not possible to prevent that a user kills your process using the "End Process" button. You can only cancel that your application will be closed if the user uses the "End Task" button:
public Form1()
{
    InitializeComponent();
    this.FormClosing += Form1_FormClosing;
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
       {
           if (e.CloseReason == CloseReason.TaskManagerClosing) // if the user tries to closes the process using the "End task" button in task manager, cancel this
           {
               e.Cancel = true;
           }
       }
Hope this helps.
  Permalink  
Comments
Marcus Kramer at 14-Jan-13 13:33pm
   
My 5.
ProgramFOX at 14-Jan-13 13:34pm
   
Thank you!
Sergey Alexandrovich Kryukov at 14-Jan-13 14:25pm
   
I also tried to explain why is it so. Please see my answer.
This answer is of course credited.
—SA
Sandeep A K at 14-Jan-13 13:35pm
   
sir,
what will happen if the user right click my application process and click the end process? will my application exit?
ProgramFOX at 14-Jan-13 13:38pm
   
Yes. There's no way to prevent that. You can only prevent closing your application if the user uses the "End Task" button, and not the "End Process" button.
Sergey Alexandrovich Kryukov at 14-Jan-13 14:14pm
   
That's correct, my 5.
—SA
ProgramFOX at 15-Jan-13 12:33pm
   
Thank you!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

[In addition to the correct answer by ProgramFOX]
 
I also want to explain why it's not possible to prevent the application process from killing through the Task Manager. In brief, this is because Task Manager is the last line of defense for a user.
 
Let's imagine for a minute that such feature is implemented in the OS, which would be technically quite possible. Let's assume this is related to application processes only, nothing executed in the kernel ring. Even in this case, it would be easy to block the operation of the whole system forever, more exactly, until the user boots from a different media and re-install the OS or modifies it.
 
The OS is designed the way that the application process cannot really hang it. But still, it can screw up the OS functionality pretty well; for example, it can consume too much of resources and never stop. Even though the OS might be not hanging, but it will be practically unusable. And it does not matter if it's done accidentally or not; the system is still not usable. The only way to fix it would be the Task Manager or similar tool, but you want to prevent it. Worse, you can easily make your offending process auto-started when the OS starts or the user logs in. This way, you would completely block the possibility to fix the problem caused by a bad application. This is too costly to allow it happen.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 254
1 Sergey Alexandrovich Kryukov 182
2 Hard_Rockz 128
3 Richard MacCutchan 125
4 Maciej Los 104
0 OriginalGriff 5,374
1 Sergey Alexandrovich Kryukov 4,713
2 Peter Leow 2,944
3 DamithSL 2,465
4 Maciej Los 2,270


Advertise | Privacy | Mobile
Web03 | 2.8.140718.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid