Hi.
Is there any way to detect if application is being killed by 'End
Process' via Task Manager ? 9 15855
"SeC" <se*****@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi.
Is there any way to detect if application is being killed by 'End
Process' via Task Manager ?
No there isn't, and that's why you should never kill an application unless the application
is blocked and none of it's threads can ever make any progress.
Willy.
Willy Denoyette [MVP] napisal(a):
"SeC" <se*****@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi.
Is there any way to detect if application is being killed by 'End
Process' via Task Manager ?
No there isn't, and that's why you should never kill an application unless the application
is blocked and none of it's threads can ever make any progress.
Willy.
Yeah, I know that, but person who uses my application don't. He can
terminate process just 'because' and I need to perform some actions
when this happen. So there is nothing I can do about it ?
"SeC" <se*****@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
>
Willy Denoyette [MVP] napisal(a):
>"SeC" <se*****@gmail.comwrote in message news:11**********************@79g2000cws.googlegr oups.com...
Hi.
Is there any way to detect if application is being killed by 'End
Process' via Task Manager ? No there isn't, and that's why you should never kill an application unless the application is blocked and none of it's threads can ever make any progress.
Willy.
Yeah, I know that, but person who uses my application don't. He can
terminate process just 'because' and I need to perform some actions
when this happen. So there is nothing I can do about it ?
As I said, No there isn't. Educate your users not to kill processes or remove "Task manager"
from the task bar by applying group policies.
Willy.
I may be putting my foot in my mouth here, and I don't have a
solution, but I think you can do this some how. I'm sure it would take
some advanced coding, but I think it can be done. I have dealt with
viruses that when you kill the process it starts right back up. I've
also had processes that have ran in such a way that Task Manager cannot
kill them at all. If the application is truely not 'locked up' and is
running, is there no que or system call that could be monitored to see
it this process in in the que or having a system call issues to kill
it, and then respond by doing some cleanup - maybe cancelling itself
from the que/system call, doing cleanup, and closing properly? If the
application is truely 'locked' then it wouldn't matter anyway.
I am not good at the current programming languages and such, but I
find things like this to fit into that 'never say never' category.
There is usually a way to do almost anything in code.
Also, you're assuming that this programmer is in a position to
enforce group policy. I write retail applications and have no power
over what is enforced though group policy, assuming they are even
running in a server based network. Messing with local policies when you
install software on someone elses machine is not good practice. And
considering you are an MVP, you have been 'computering' for a bit and
you know users will not listen to you many times and will do what they
want, when they want, and then tell you they didn't do it!
Look into this more, I'll bet you 99.99% chance this can be done
some way.
Willy Denoyette [MVP] wrote:
"SeC" <se*****@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
Willy Denoyette [MVP] napisal(a):
"SeC" <se*****@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi.
Is there any way to detect if application is being killed by 'End
Process' via Task Manager ?
No there isn't, and that's why you should never kill an application unless the
application
is blocked and none of it's threads can ever make any progress.
Willy.
Yeah, I know that, but person who uses my application don't. He can
terminate process just 'because' and I need to perform some actions
when this happen. So there is nothing I can do about it ?
As I said, No there isn't. Educate your users not to kill processes or remove "Task manager"
from the task bar by applying group policies.
Willy.
"Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+" <am******@hotmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
I may be putting my foot in my mouth here, and I don't have a
solution, but I think you can do this some how. I'm sure it would take
some advanced coding, but I think it can be done. I have dealt with
viruses that when you kill the process it starts right back up. I've
also had processes that have ran in such a way that Task Manager cannot
kill them at all. If the application is truely not 'locked up' and is
running, is there no que or system call that could be monitored to see
it this process in in the que or having a system call issues to kill
it, and then respond by doing some cleanup - maybe cancelling itself
from the que/system call, doing cleanup, and closing properly? If the
application is truely 'locked' then it wouldn't matter anyway.
I am not good at the current programming languages and such, but I
find things like this to fit into that 'never say never' category.
There is usually a way to do almost anything in code.
Also, you're assuming that this programmer is in a position to
enforce group policy. I write retail applications and have no power
over what is enforced though group policy, assuming they are even
running in a server based network. Messing with local policies when you
install software on someone elses machine is not good practice. And
considering you are an MVP, you have been 'computering' for a bit and
you know users will not listen to you many times and will do what they
want, when they want, and then tell you they didn't do it!
Look into this more, I'll bet you 99.99% chance this can be done
some way.
Well, let me be more specific, I'm talking about the "kill" in OP's question while he's
asking about the "End process". So my previous answer "No it can't be done" might be wrong,
all depends on why the user decides to use 'Taskman' to terminate an application, let me
explain.
Using "End task" in taskman will try to "End a process" or try to "Kill " a process,
taskman's "End process" will ask the OS to send a WM_CLOSE message to the UI thread
messagequeue or a CTRL_CLOSE_EVENT to a console program. Both of these can be handled by the
offending application. If the application does not respond to the message or the event in a
timely fashion, the OS will "kill" the process by calling Win32's "TerminateProcess" API.
The latter cannot be trapped, simply because no more user code will run in that process, the
user portion of a process is cleaned up without returning a thread quantum to the process,.
Note that here I'm saying user portion, a process that get's stucked into kernel space (say
in a driver) won't go away completely (only the user's portion will) if the (badly behaving)
driver doesn't clean-up and return to the OS, this is what you may have noticed using
taskman.
Now the whole question is - why does the end-user use taskman to *end* a task? Isn't it
easier to close/exit the application in a normal way? My guess is that the application is
stucked somewhere (endless loop, dead-locked, locked in kernel, etc..) and the user has no
other means than using "taskman" to terminate the application, but *if* the application is
stucked somewhere it cannot handle the message/event and it will get "killed" by
'TerminateProcess" which cannot be trapped and that was my exact point.
Willy.
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote:
>Using "End task" in taskman will try to "End a process" or try to "Kill " a process, taskman's "End process" will ask the OS to send a WM_CLOSE message to the UI thread messagequeue or a CTRL_CLOSE_EVENT to a console program. Both of these can be handled by the offending application. If the application does not respond to the message or the event in a timely fashion, the OS will "kill" the process by calling Win32's "TerminateProcess" API.
Now the whole question is - why does the end-user use taskman to *end* a task? Isn't it easier to close/exit the application in a normal way?
I use the taskman "end task" as the standard way to exit several of my
utilities -- the small ones that run in the background and have no
user-interface as all. E.g. my "keymouse" program which turns the
right-alt-key into a virtual right-mouse-button (for people whose mice
have only one button...) http://www.wischik.com/lu/Programmer/Keymouse
And exactly as you say, all I do is handle the WM_CLOSE message to do
the tidying up.
As for educating the user not to use EndProcess? My instinct is to
write a registry key when the application starts, and clear it when
the application ends. Upon application startup I check the key. If it
has been set then I pop up a box saying "Sorry, this application seems
to have crashed last time it was run. Where possible, try to exit the
application through File>Exit."
--
Lucian
"Lucian Wischik" <lu***@wischik.comwrote in message
news:al********************************@4ax.com...
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote:
>>Using "End task" in taskman will try to "End a process" or try to "Kill " a process, taskman's "End process" will ask the OS to send a WM_CLOSE message to the UI thread messagequeue or a CTRL_CLOSE_EVENT to a console program. Both of these can be handled by the offending application. If the application does not respond to the message or the event in a timely fashion, the OS will "kill" the process by calling Win32's "TerminateProcess" API.
Now the whole question is - why does the end-user use taskman to *end* a task? Isn't it easier to close/exit the application in a normal way?
I use the taskman "end task" as the standard way to exit several of my
utilities --
Why not use the "regular" way to end a task, that is click close or Exit, is beyond me. My
guess is that you talk as a developer, you know exactly how your utilities behaves when they
get terminated from an 'external' program, a regular user should never use taskman to end a
task, he simply doesn't (and shouldn't) know what's happening when he 'kills' a task from
Taskman. I know <start rantpeople don't care that much about this all and keep running as
"administrator", kill other processes, inspect memory consumption using taskman without
knowing what memory really is, blame Windows, MSFT etc..when things go wrong when they
(Inadvertly ?) killed Winlogon or CSRSS.EXE etc., it's great to see Vista trying to get an
end to this, but as the saying goes "bad habbits never die", that's why we see a lot of
interest in turning off UAC<end rant>.
the small ones that run in the background and have no
user-interface as all. E.g. my "keymouse" program which turns the
right-alt-key into a virtual right-mouse-button (for people whose mice
have only one button...) http://www.wischik.com/lu/Programmer/Keymouse
And exactly as you say, all I do is handle the WM_CLOSE message to do
the tidying up.
Here you mean your UI type utilities, right?, WM_CLOSE is only posted to UI threads.
>
As for educating the user not to use EndProcess? My instinct is to
write a registry key when the application starts, and clear it when
the application ends. Upon application startup I check the key. If it
has been set then I pop up a box saying "Sorry, this application seems
to have crashed last time it was run. Where possible, try to exit the
application through File>Exit."
Why not handle the WM_CLOSE and tell the user he should terminate the application through
File>Exit?
Willy.
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote:
>Why not use the "regular" way to end a task, that is click close or Exit, is beyond me.
As I said, for minimal background utilities that are too small for a
UI to be worth it (e.g. a system tray icon). So there is no place to
click Close or Exit. The task manager "Task List" is the neatest place
to list the running utility and be able to close it.
>And exactly as you say, all I do is handle the WM_CLOSE message to do the tidying up.
Here you mean your UI type utilities, right?, WM_CLOSE is only posted to UI threads.
Come on, this is Windows. Even utilities without a UI still often need
a UI thread. (e.g. in the example I posted, it's disallowed to install
a keyboard hook unless you have a UI thread.)
Also, if you want the application to appear in the task list so that
users can close it, then it needs a UI thread and a window, even
though that window is invisible and WS_EX_NOACTIVATE.
>As for educating the user not to use EndProcess? My instinct is to write a registry key when the application starts, and clear it when the application ends. Upon application startup I check the key. If it has been set then I pop up a box saying "Sorry, this application seems to have crashed last time it was run. Where possible, try to exit the application through File>Exit."
Why not handle the WM_CLOSE and tell the user he should terminate the application through File>Exit?
The exercise is to educate the user not to use "End Process".
When the user terminates the program through "End Task" (->WM_CLOSE)
or clicking on the close box (->WM_CLOSE) or File>Exit, the original
poster is able to trap this and do the cleanups he needs.
He was concerned about users who use "End Process" where he can't trap
it and clean up.
Anything that produces WM_CLOSE is fine, from his perspective, so
there's no need to educate the user against it.
--
Lucian
"Lucian Wischik" <lu***@wischik.comwrote in message
news:n0********************************@4ax.com...
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote:
>>Why not use the "regular" way to end a task, that is click close or Exit, is beyond me.
As I said, for minimal background utilities that are too small for a
UI to be worth it (e.g. a system tray icon). So there is no place to
click Close or Exit. The task manager "Task List" is the neatest place
to list the running utility and be able to close it.
>>And exactly as you say, all I do is handle the WM_CLOSE message to do the tidying up.
Here you mean your UI type utilities, right?, WM_CLOSE is only posted to UI threads.
Come on, this is Windows. Even utilities without a UI still often need
a UI thread. (e.g. in the example I posted, it's disallowed to install
a keyboard hook unless you have a UI thread.)
A process that has a UI thread (that is, has a Window registered, a message queue and a
message pump) is what I call a UI style application (or utility as you named it) , it
doesn't matter whether the window is invisible or not.
Also, if you want the application to appear in the task list so that
users can close it, then it needs a UI thread and a window, even
though that window is invisible and WS_EX_NOACTIVATE.
>>As for educating the user not to use EndProcess? My instinct is to write a registry key when the application starts, and clear it when the application ends. Upon application startup I check the key. If it has been set then I pop up a box saying "Sorry, this application seems to have crashed last time it was run. Where possible, try to exit the application through File>Exit."
Why not handle the WM_CLOSE and tell the user he should terminate the application through File>Exit?
The exercise is to educate the user not to use "End Process".
When the user terminates the program through "End Task" (->WM_CLOSE)
or clicking on the close box (->WM_CLOSE) or File>Exit, the original
poster is able to trap this and do the cleanups he needs.
He was concerned about users who use "End Process" where he can't trap
it and clean up.
Anything that produces WM_CLOSE is fine, from his perspective, so
there's no need to educate the user against it.
So, you are telling your users that it's OK to use "End task" but NOT "End process" from
Taskman and all of them do follow this advise? Well, that' s great for you, but our policy
is somewhat different, all users that logon into their domain account to run business
critical applications cannot use taskman (through GPM), this is something we learned the
hard way since Windows NT4 was introduced in the company a decade ago, this is not about
trusting your users (you can't trust all of them), this is about safety. And, No, we don't
install utilities that need to be started/terminated by the user that don't have a minimal
UI with 'close' or 'exit'.
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stephane Belzile |
last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS
unit in case of power failure?
Thanks
|
by: Will Haney |
last post by:
I have a .NET application that needs to perform some last moment
duties upon termination. The application has no forms with one
Module containing the Sub Main. How can I detect/trap the...
|
by: Ana |
last post by:
Hi!
I have problems with the following scenario:
My application is developed using C# under .NET. It must run on all Windows
versions starting from Windows 98.
The user must open different...
|
by: Barry Mossman |
last post by:
Hi,
can I detect whether my class is running within the context of a Console
application, vs say a WinForm's application ?
also does anyone know whether the compiler or runtime is smart enough...
|
by: Stephen Walch |
last post by:
I have a managed library that needs to behave differently when used in an
ASP.NET web page as apposed to a WinForms app. What is the most efficient
way to detect this at run time? (Bonus...
|
by: Jeremy |
last post by:
Hello,
I'm thinking this may be an easy one but I am getting frustrated. How
can I detect if a process is showing a modal dialog. Like "Are you sure
you want to exit?", or an error message...
|
by: Jeremy |
last post by:
I apologize for the repost but I am frustrated and desperate for a
solution.
I need to detect if an external application is displaying a modal form.
I.E. dialog box or error message.
I found...
|
by: BJ |
last post by:
Problem: How can I code up a client side process to detect if the
network is available?
Synopsis: I am writing ASP.NET input forms for a Panasonic Tuff book.
The users will be walking around...
|
by: e-Ricc |
last post by:
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...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
| |