Saint
Saint

Reputation: 5469

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 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?

Upvotes: 2

Views: 612

Answers (2)

Saint
Saint

Reputation: 5469

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

Upvotes: 0

Daniel B
Daniel B

Reputation: 2887

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.

Upvotes: 3

Related Questions