0

Lets call the app I need to close A. The problem I have is that A starts an other application, lets call it B.

So if I close A, B is still running.

The reason why I need to also close B is because if I restart A after I closed it, it does not work properly, because a B app is already running because a previous A started it.

I only know the path to the A application.

Sysinternals Procmon can see that they have this starter-started relationship, but how can I?

A and B application in SysInternals Procmon

I'm writing my closer app in Delphi, but I'm open to any alternative solutions.

Thanks.

Sevron
  • 493
  • 7
  • 18
  • would be so much easier if vrayspawner would set the appropriate job policies to arrange that children would be killed by the system when the parent closes – David Heffernan Sep 20 '16 at 10:56
  • Yeah it is a 3rd party software, so I have no control over what they do about that. – Sevron Sep 20 '16 at 11:00
  • I would try another approach, batch command`taskkill /F /T /PID 1234`. This should work as long as the child processes do not have children themselves. Make sure to run it as administrator. There is also a variant with process name instead of ID: `taskkill /F /T /IM vrayrtspawner.exe`. – quasoft Sep 20 '16 at 20:49
  • If you really want to do it in Delphi, follow this answer to enumerate processes http://stackoverflow.com/a/21031247/2939061. Then get the process ID of process A and find all processes with `th32ParentProcessID` (from `pe` record) equal to `th32ProcessID`. Those should be your candidate B processes. Then use some method to check if the process ID of the parent has not changed (eg. check start time of process as suggested in the duplicate question above). This is kind of unsafe - you can mistakenly kill a process with reused ID, but you could also check names of candidate B processes. – quasoft Sep 20 '16 at 21:00
  • By the day this does not seem like an exact duplicate of that question, seems more close to http://stackoverflow.com/a/21031247/2939061. – quasoft Sep 20 '16 at 21:05
  • @quasoft, yeah I know it is not a duplicate but there is nothing I can do against it, kind of annoying.. Anyways thank you for the recommendation, I will try them today. – Sevron Sep 22 '16 at 07:52

0 Answers0