|
Still suspicious. Create something like the NT services.
The word "politics" describes the process so well: "Poli" in Latin meaning "many" and "tics" meaning "bloodsucking creatures."
जय हिंद
|
|
|
|
|
If the machine's user has the prerequisite knowledge on how to terminate a process, your process is toast. Nothing you can do.
You could use a service to respawn it, but if the service is knobled first you're screwed again.
If it is a client/server network app then use a heartbeat of some kind to detect machines with the "class viewer" no longer active and report it to the admin.
Bar fomos edo pariyart gedeem, agreo eo dranem abal edyero eyrem kalm kareore
|
|
|
|
|
If the users don't have admin privileges start it automatically with a service in an account that does and restart it as needed*. If they have admin privileges there's nothing you can do.
* in theory you could have the GUI in the service itself, but that's not a good idea, since Bad Things happen when your service tries to create a GUI object when no one's logged in and there isn't a desktop to create it on.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
is it ok to catch a newProcess_event and run the code below?
foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses())
{
if (p.ProcessName == "taskmgr")
p.Kill();
}
but the question is that how i can look for the newProcess_event ?
|
|
|
|
|
If you think people wont notice that they can't open task manager then you're mistaken. You're not going to get help, or succeed.
|
|
|
|
|
i dont think this was an answer, do u have a better solution?
|
|
|
|
|
Yes, accept failure and quit trying. You clearly have malicious intent, no one is going to help you, what don't you understand?
|
|
|
|
|
i can not understand what do u mean by malicious intent, is there any problem that only administrators can close an application?
a class viewr client app should not be closed by a student?!!!
|
|
|
|
|
spiritboy wrote: Im trying to detect when a user "kills" my c# app using windows task
manager(so i can prevent it)
First time you mention Administrator to any of us. You're just trying to find a way to weasel the information, it isn't going to happen. Sorry.
|
|
|
|
|
spiritboy wrote: i've tried with the form events _closing and _closed managing but it won't satisfy me
What do you mean "it won't satisfy me"? Are you not able to determine the reason the form is closing or is it that you're unable to prevent the form from closing when the app is terminated via Task Manager?
/ravi
|
|
|
|
|
He is trying to make his application unclosable.
|
|
|
|
|
|
because when the form is closed by taskmanager then i can not cancel it by _closed event,( taskmanager forces to close the form)
and the result ... is closing the form that wont satisfy me
|
|
|
|
|
But can't you start a new instance of the app when it's closed by TaskManager?
/ravi
|
|
|
|
|
yes this is another way but i need a starting point on how to do that?
i have searched alot and find a way: a watcher app to take care of my app. but what would happen if my watcher closed by taskmgr, then my form can also be easily closed
|
|
|
|
|
See my reply to Dave K.
/ravi
|
|
|
|
|
The only acceptable method is to write a service that monitors the process list and relaunches the application you're trying to keep open. Preventing the launch of Task Manager is not an acceptable solution in any legitimate environment.
The events in your application will not help you at all. Task Manager can kill a process just by stopping it's execution and freeing the memory it uses. Your app will never know what hit it.
|
|
|
|
|
Dave Kreskowiak wrote: Your app will never know what hit it.
Not really. The app receives a FormClosing event with CloseReason = CloseReason.TaskManagerClosing . Cancelling the close will cause TaskManager to display "The app you're trying to close is not responding.", allowing you to cancel the kill or "force" a kill. Because we're able to handle the event, we can start a new instance.
Dave Kreskowiak wrote: The only acceptable method is to write a service
I don't think a service can be safely used to start a desktop app since a service can start before a desktop exists.
/ravi
|
|
|
|
|
so u mean that it is enough to just specify new instance of my app, when the form _closed?
|
|
|
|
|
No, it's not. You have your applications state to worry about. What happens if the app is restarted?
And Ravi's suggestion does not work 100% of the time and is also dependant on the version of the .NET Framework you wrote the app against. Not every version supports telling you that TaskManager is responsible for closing your app. The FormClosing event and CloseReason enumeration didn't show up until .NET 2.0.
|
|
|
|
|
See my directly emailed reply.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: Not really. The app receives a FormClosing event with CloseReason = CloseReason.TaskManagerClosing. Cancelling the close will cause TaskManager to display "The app you're trying to close is not responding.", allowing you to cancel the kill or "force" a kill. Because we're able to handle the event, we can start a new instance.
I tried it some time ago and my but it didn't happen. My app was just killed.
|
|
|
|
|
Ravi Bhavnani wrote: Dave Kreskowiak wrote:
Your app will never know what hit it.
Not really.
I said it CAN close an app that abuptly. I know TM tries to close an app nicely at first, then if that doesn't succeed, it wips out the shotgun and takes aim.
Ravi Bhavnani wrote: I don't think a service can be safely used to start a desktop app since a service can start before a desktop exists.
If done properly, yes, it can. That includes checking to see if someone is actually logged on, who that person is, and if they have permissions to use the app.
|
|
|
|
|
Dave Kreskowiak wrote: If done properly, yes, it can. That includes checking to see if someone is actually logged on,
That's a good point.
Dave Kreskowiak wrote: I know TM tries to close an app nicely at first,
What I was suggesting is the app could allow itself to be closed and simply restart another instance when shutdown by the TM. Because the app gracefully shuts down, it can "pick up where it left off".
/ravi
|
|
|
|
|
I think you all being too mean. Sometimes there may be a valid reason for his requirements. In large network environments its common to want to administer applications that cannot be closed by the user.
And besides if he has bad intentions the fact that he needs to know this kind of thing goes to show he wont be creating some revolutionary super virus lol
You can try hiding the applciation from view and from the task bar, that may stop users knowing its there.
But your best bet is prob to look into creating a service, but i have not done one before so ask google or someone of the same intelligence level.
Thou i would image network administrators would be able to do something with permissions. Im not one thou so who knows
|
|
|
|