0

I have a Console Application (App1) which runs before other application (App2) and confirm or reject by returning an error code the launch of App2. When App1 return error code 0 - App2 being launched and if the error code is different than 0, App2 close it self with showing a suitable message to the user.

This simple flow works great but I have one issue that I need to solve. It seems that when the user kill App1 by using Ctrl+Alt+Del the returned error code is 0 and then App2 runs. Is there any way to solve this issue? is it possible to catch some event before the application being killed? Thanks Ofir

Ofir
  • 5,049
  • 5
  • 36
  • 61
  • How does your App2 knows the return code of App1 if it was killed? Does App2 spawn App1 and waits for it's completion? (Other options would be checking whether App1 ended correctly by App1 writing a file and deleting in on exit. If the file remains then the App1 was killed in progress) – Samuel Oct 09 '13 at 06:24
  • Does the app gets terminated on ctrl+alt+del ? It will just open task manager isn't it? – Sriram Sakthivel Oct 09 '13 at 06:41
  • It seems there is a clash in your errorcode, why not change the exitcode to some different number? – Sriram Sakthivel Oct 09 '13 at 06:42
  • @Sriram Sakthivel, I thought about your solution, App2 is an app of external vendor so I need to send a request and wait for a solution. If I won't find easier solution I will do it. – Ofir Oct 09 '13 at 06:57
  • @Samuel, for your question, yes App2 spawn App1 but as I said to Sriram Sakthivel, App2 is a product of external vendor so I don`t have direct control about it implementation. I need to open a request to App2 product owner for any changing requset – Ofir Oct 09 '13 at 06:59
  • 1
    If you're talking about detecting kill process from `TaskManager` then that's gonna be hard. You can do that by `dll injection`, you've to hook the `TerminateProcess` api which is located in `kernel32.dll` etc... best thing is think for a alternative solution rather than detecting termination of process. – Sriram Sakthivel Oct 09 '13 at 07:02
  • I assume that there is no a simple answer for my question. I think I will contact App2 owner and solve it with him. Thank you all – Ofir Oct 10 '13 at 15:01

0 Answers0