1

I need to get process id of the newly created process with help of ProcessStartInfo class here's my code

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "chrome.exe";
startInfo.Arguments = "--app=http://www.google.com/";
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
Console.WriteLine(p.Id);

However it return an ID which is not the id of the process chrome.exe process. I have verified the presence of chrome.exe process in PowerShell with different Process ID

Thanks in Advance.

Prasanth
  • 99
  • 2
  • 10
  • Quick search on stackoverflow-http://stackoverflow.com/questions/12892268/getting-pid-of-process-started-by-process-start – Nico Oct 11 '13 at 11:13

1 Answers1

3

Chrome will run multiple processes with one parent process creating a number of child processes. When you run Chrome from the command line your new Chrome process will most likely communicate with an existing Chrome process (the parent I guess) and then exit which explains the behavior you see.

Martin Liversage
  • 104,481
  • 22
  • 209
  • 256