Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a cafemanager application server & client. I want to prevent my client application to be ended from task manager by users because the server application can no longer communicate to the workstation when it closes. Like antiviruses did saying access denied. I dont want to disable task manager because it is helpful when games crashes..
Posted
Comments
CoderPanda 25-Feb-14 2:04am    
Interesting question. I don't have an answer for sure. But if I am allowed to guess, you may want to create a windows user group on the workstation that doesn't have rights to kill processes. Not sure if such a thing is possible either.

Hi Weecom,

I would suggest you to hide your application from the task manager if you could.
Then how user can end the your application from Task manager.

You could refer this link for the same[^].

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
Comments
weecom 25-Feb-14 19:14pm    
Just like antiviruses(ex.avira) did saying "access denied" when task manager tries to end its process. The process is visible and I wonder how they do that. Some says through windows service but I haven't tried.Need more research on this. Thanks!
Hi Weecom

With this code you can check in your main form (event me.FormClosing) who try to close your application:

VB
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
   Select Case e.CloseReason
     Case CloseReason.ApplicationExitCall
       MsgBox("'ApplicationExitCall' tries to close application", MsgBoxStyle.Information, "CloseReason")
     Case CloseReason.FormOwnerClosing
       MsgBox("'FormOwnerClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
     Case CloseReason.MdiFormClosing
       MsgBox("'MdiFormClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
     Case CloseReason.TaskManagerClosing
       e.Cancel = True
       MsgBox("'TaskManagerClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
     Case CloseReason.UserClosing
       MsgBox("'UserClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
     Case CloseReason.WindowsShutDown
       MsgBox("'WindowsShutDown' tries to close application", MsgBoxStyle.Information, "CloseReason")
     Case CloseReason.None
       MsgBox("'None' tries to close application", MsgBoxStyle.Information, "CloseReason")
     Case Else
       MsgBox("'Else' tries to close application", MsgBoxStyle.Information, "CloseReason")
   End Select
 End Sub



with e.Cancel = True you can avoid the first try to abort the application by Task Manager or other CloseReasons

Hope this can help you.

Regards Markus
 
Share this answer
 
Comments
weecom 25-Feb-14 19:10pm    
Hi sir! thanks for the comment..I already tried this but this only works if the application terminates normally.No event is raised when the application process is ended by task manager.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900