Id from Process.Start match sometimes or sometimes not
I'd like to run from C# code ANSYS Fluent exe file
And now for comparison, I'll give 开发者_StackOverflow社区two examples
Process fluent = Process.Start(@"C:\Program Files\ANSYS Inc\v130\fluent\ntbin\win64\fluent.exe", @"2ddp file.jou");
Process browser = Process.Start("IExplorer.exe", "http://www.google.com");
Why is the browser.ID
in C# code the same as in TaskManager? Why is fluent.ID
in code different than in TaskManager ?
It's because of Fluent's characteristics or I make some mistake?
And main question: how to run Fluent and catch its ID in C# code?
It's almost certainly something to do with Fluent's characteristics. If you can't get (a relevant) PID out of Process.Start, you might need to resort starting the process, and then going into a wait-loop and attempting to retrieve the process by name (see: Process.GetProcessesByName - I think you'd pass in the EXE's name without the .exe).
Exactly how robust this solution would be depends on how well you can predict Fluent's characteristics, which is already looking quite difficult. I would definitely recommend using Process Explorer (as suggested above), as well as getting familiar with the other SysInternals tools, they give tons of insight in these cases.
Answer Daniel B is ok, but if I need launch several instances of Fluent it doesn't work. So the best solution I found is appropiate CommandLine
arguments and then searching in Task Manager
精彩评论