Is there a simple way to catch all cmd.exe instances that are currently running on Win10 to afterwards close them?
My problem is that my stress test c# application initiates multiple instances of a program that is started as follows:
private List<Process> procs = new List<Process>()
public void StartExe(...) {
//...
for (int i = 1; i <= clientcount; i++)
{
var proc = Process.Start(filename,
String.Concat(bucketNrString, " ", waitMinString, " ", waitMaxString, " ", syshostname, " ", username, " ", pw, " ", searchstring));
procs.Add(proc);
}
}
But after the loop has been iterated through, my list of processes is empty again and thus I cannot kill the processes.
Accordingly I either search for an option to catch the processes and keep them in my "procs" list, or to just kill all instances of cmd.exe which would have same result even though it is not a 100% clean solution.
I am using .NET Framework 4.8 in my application.