Reputation: 83
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.
Upvotes: 1
Views: 3103
Reputation: 106926
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.
Upvotes: 3