That's what I'm doing

Process process = new Process(); process.StartInfo.FileName = @"C:\Users\inatoff\Desktop\test.jar"; process.Start(); 

and test.jar, in turn, will launch Pipeline process_id of which I need to get the only thing that allows me to get this kostylina of this type:

 var time = process.StartTime; Thread.Sleep(200); var wantedProcessId = Process.GetProcesses().First(p=>p.StartTime==time); 

Tell me, please, a highly respected community.

    1 answer 1

    Well, knowing the parent process, you can always get child processes, like this:

     var parrentProcess = Process.Start(@"C: \Users\inatoff\Desktop\test.jar"); // NOTE: Process Ids are reused! ManagementObjectSearcher searcher = new ManagementObjectSearcher( "SELECT * " + "FROM Win32_Process " + "WHERE ParentProcessId=" + parrentProcess.Id); List<Process> jarProcesses = new List<Process>(); foreach (ManagementObject mo in searcher.Get()) jarProcesses.Add(Process.GetProcessById(Convert.ToInt32(mo["ProcessID"]))); 

    Source

    • and if the parent has 200 such processes? but I need this one, let's say so - to get its PID during the launch - inatoff