When starting a process in VB.Net, I would like to be able to identify it to later kill it and all its children if necessary.
I launch my process this way :
Dim mainProcessHandler As New ProcessStartInfo()
Dim mainProcess As Process
mainProcessHandler.FileName = "something_01out18.bat"
mainProcessHandler.Arguments = "-d"
mainProcessHandler.WindowStyle = ProcessWindowStyle.Hidden
mainProcess = Process.Start(mainProcessHandler)
If I do a
mainProcess .Kill()
it will close all cmd windows opened. But none of any other process that have been launched by the bat script.
I'm pretty sure that the OS give an ID to my process when I start it but I didn't succeed to get it. If that not the case, I didn't find either how to give a ID myself to the process.
At the end of the day, I would like to list all child processes, kill them, kill the father process but none of the other "cmd" process running on the PC.
Is there a way to do such things ?