473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 13236
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John E. Hadstate | last post by:
Please forgive the heavy cross-posting and feel free to delete inappropriate groups when you reply. I am really at a loss and hope someone has an answer for my problems. Environment: Redhat...
1
by: Tom | last post by:
I've forgotten how to add a particular line to the task list in vs2003 before there was a context menu that you can click on to add something to task and come back to later.. but now I can't find...
2
by: Julio Allegue | last post by:
I am getting the wrong Count(*) on vb.net using the ExecuteScalar . It returns all the rows. It doesn't seem to look at the WHERE clause. At the same time, I am getting the correct count on "SQL...
4
by: Leeor Chernov | last post by:
Hi , I Used the object Excell Application(COM INTEROP) and it is staying as an open process, And the owner(User Name) is ASPNET Altough I try to release it with :...
0
by: AJ2 | last post by:
Hi Guys, I included "for xml auto" in sql statement in "Excute SQL Task" and aimed to dump the output to a flat file. I added "ActiveX Script Task" into my package and with the following lines: ...
8
by: Henrik | last post by:
Hi Is there any way to see what the System process is doing? We have developed an application running at a production site to measure and optimize the production. The application needs to be...
1
by: Brad Pears | last post by:
I am working on a vb .net 2005 project. Recently I wanted to changed the location of my builds from debug to release. I clicked on the 'Build option and for some unknown reason, the "configuration...
4
by: AliRezaGoogle | last post by:
Dear Members I have a critical program written in c#. It runs every time the user log on. But sometimes log-oned user forces my application process to quit by “End Process” in task manager. How...
4
by: tvnaidu | last post by:
How can I cheack CPU load on LINUX like "Windows Task manager" on Windows?. Windows task manager shows CPU load (percentage) and etc, any tool in LINux?. I know "top" command which shows which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.