471,571 Members | 3,548 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,571 software developers and data experts.

detect "task manager end process"

Hi guys!

Im trying to detect when a user "kills" my c# app using windows task
manager, i've tried with the form events _closing and _closed managing
for example putting an if inside to detect it:

if (e.CloseReason == CloseReason.TaskManagerClosing)
{
MessageBox.Show("from task manager");
}

but it doesn´t works, any idea?

Regards
Ricc
Oct 10 '07 #1
4 12861
Hello e-Ricc,

u need to inject dll into the taskmanager, hooking the TerminateProcess in
Kernel32
and such u can add your custom code

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
eHi guys!
e>
eIm trying to detect when a user "kills" my c# app using windows task
emanager, i've tried with the form events _closing and _closed
emanaging for example putting an if inside to detect it:
e>
eif (e.CloseReason == CloseReason.TaskManagerClosing)
e{
eMessageBox.Show("from task manager");
e}
ebut it doesn?t works, any idea?
e>
eRegards
eRicc
Oct 11 '07 #2
"e-Ricc" <rk****@hotmail.comwrote in message
news:ew**************@TK2MSFTNGP04.phx.gbl...
Hi guys!

Im trying to detect when a user "kills" my c# app using windows task
manager, i've tried with the form events _closing and _closed managing for
example putting an if inside to detect it:

if (e.CloseReason == CloseReason.TaskManagerClosing)
{
MessageBox.Show("from task manager");
}

but it doesn´t works, any idea?

Regards
Ricc


This event (TaskManagerClosing) is raised when the "Task" is terminated, not
when the "Process" is terminated, the latter stops the process cold, no
events are raised, so there is nothing you can do from within the
application itself.
One solution for this is to Remove Taskman from the taskbar using Group
Policy Management (Local Computer Policy), sure this isn't of any help if
the user has other means to kill a running process.

To watch process termination events, you can run a watchdog (needs
administrative privileges!) which listens for WMI "Win32_ProcessStopTrace"
events using System.Management 's ManagementEventWatcher.

Willy.

Oct 11 '07 #3

<Michael Nemtsev>; "MVP" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
Hello e-Ricc,

u need to inject dll into the taskmanager, hooking the TerminateProcess in
Kernel32
and such u can add your custom code
Would work I suspect, but no user would ever voluntarily use software that
does such a thing.
>
---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

eHi guys!
eeIm trying to detect when a user "kills" my c# app using windows task
emanager, i've tried with the form events _closing and _closed
emanaging for example putting an if inside to detect it:
eeif (e.CloseReason == CloseReason.TaskManagerClosing)
e{
eMessageBox.Show("from task manager");
e}
ebut it doesn?t works, any idea?
eeRegards
eRicc


Oct 15 '07 #4

Oki doki!

let me look for info, thanks!!

Regards
e-Ricc
Ben Voigt [C++ MVP] wrote:
<Michael Nemtsev>; "MVP" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
>Hello e-Ricc,

u need to inject dll into the taskmanager, hooking the TerminateProcess in
Kernel32
and such u can add your custom code

Would work I suspect, but no user would ever voluntarily use software that
does such a thing.
>---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

eHi guys!
eeIm trying to detect when a user "kills" my c# app using windows task
emanager, i've tried with the form events _closing and _closed
emanaging for example putting an if inside to detect it:
eeif (e.CloseReason == CloseReason.TaskManagerClosing)
e{
eMessageBox.Show("from task manager");
e}
ebut it doesn?t works, any idea?
eeRegards
eRicc


Oct 15 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tom | last post: by
8 posts views Thread by Henrik | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.