Hi,
I wonder if there is a way to detect a deletion of an app when it's running? Lets say I have an app which is running in background and I want to delete it. Is there a way to detect this deletion by this app?
Best Regards.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Feb 20, 2012, 11:05 PM
There are things that can be done without programming, such as disabling a user from having permission to use the Task Manger. Note that preventing use of the Task Manager might seem to be a good solution but it is not if the user finds a similar utility to do what they want to do and there are plenty of them.
It really depends on why you need to do this. If you are doing this because an employer needs to ensure that the employee is doing something then there might be non-programming solutions. If you are doing it because the user does not like your software and they want to get rid of it from their system then the solution might be to make the program more "user-friendly". So the solution depends on many things.
VulpesPosted Feb 20, 2012, 8:50 AM
If you're writing a 'kiosk' app which you don't want the user to close, then I'd just trap the closure by handling the Process.Exited event and then restart it again with Process.Start.
RaysefoPosted Feb 20, 2012, 1:38 AM
Thanks for your quick reply. Let me change the question. Is there a way to avoid end a running process??? I mean If user tries to kill process from task manager or etc.
Best Regards.
VulpesPosted Feb 19, 2012, 2:01 PM
However, you can detect when an application ends by handling the Process.Exited event:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.exited.aspx
It would then be possible to programatically delete the application's file by using the System.IO.File.Delete method.
In case you don't know already, you can also terminate a running app programatically using the Process.CloseMainWindow method, if it's a GUI app, or the Process.Kill method otherwise:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.closemainwindow.aspx
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill.aspx