getting PID of process started by Process.start()

前端 未结 4 998
礼貌的吻别
礼貌的吻别 2020-12-01 08:19

I am starting an executable using this code:

Process proc = new Process();
proc.StartInfo.FileName = executablePath;
proc.Start();
proc.WaitForInputIdle();
<         


        
4条回答
  •  眼角桃花
    2020-12-01 08:26

    Below also returns the PID of a process

    Process[] p = Process.GetProcessesByName("YourProcessName");
    

    Now you can get process Id by using p[i].Id;

提交回复
热议问题