title: Making an app/service such that trying to end/kill its process in Task Manager would result in "Unable to Terminate Process"
body: <p>I have an Avast antivirus and it has a process "AvastSvc.exe". If I try to end/kill that process in Windows Task Manager, then a windows with the following messages appears: "Unable to Terminate Process", "The operation could not be completed.", "Access is denied". Trying to end some system Windows processes (like winlogon.exe) may feature the same behaviour (although once I managed to kill winlogon.exe and got my machine hanged!).</p>
  
  <p>I want my application (possibly, converted to a service) behave in the same way. How can I do this?</p>
  
  <p><a href="https://stackoverflow.com/questions/7254595/disable-windows-task-manger-so-he-cant-kill-my-process">Disable Windows Task Manager so he cant kill my process</a> is a similar question which has many interesting answers, but they don't seem to feature the technique which is used by the above antivirus and results in "Unable to Terminate Process" message.</p>
  
  <p><a href="http://forums.codeguru.com/showthread.php?t=503337" rel="nofollow noreferrer">http://forums.codeguru.com/showthread.php?t=503337</a> has a solution on how to prevent <em>stopping</em> a service (eg, via services.msc console), but I need preventing <em>ending/killing</em> its process in Task Manager.</p>
  
  <p>I am writing the app in C++/winapi, no CLR/.Net, under Windows 7.</p>
  
  <p>UPDATE on permissions:
  Antivirus process AvastSvc.exe is owned by "system" account. However, I have other processes owned by "system" account, and they are killable and antivirus is not. Also, I compared executable permissions and owners of antivirus process and ones of killable processes, and I don't see any difference.</p>
  
  <p>UPDATE on user control and purpose of the software:
  The software functionality is somewhere between that of system and business software. The nature of the software requires it to run on a permanent basis. The application itself will have a "turn off" action, and we want to encourage users to use it and discourage them from killing the process (it's similar to what antiviruses do). I understand that it's not possible to completely prevent users from killing it, but I want to make it harder. This question is <em>specifically</em> about the way described above ("Unable to Terminate Process") which some services (like Avast) use to prevent killing their processes. It is sufficient for me to achieve just the same behavior. Also, users will be  able to just uninstall the software if they don't like it/don't need it anymore. </p>