I have the same problem in this link, but the problem is I want to automate this process in an executable file, without the need to kill first PIDs every time. in fact, I want my executable file to detect these PIDs each time, and then kill them if necessary.
Do you have any idea how to do so?