2

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?

Saint
  • 5,397
  • 22
  • 63
  • 107
  • 1
    Random guess, its a java app and the processid is the host javaw? is the ID listed elsewhere in task manager against another process? – Alex K. May 31 '11 at 15:07
  • 3
    Even if it is not a java app, the `fluent.exe` you call might still start another child process (even of itself) that actually runs, as @Alex K. said. That would also result in different process IDs being observed in C# and Task Manager. Without having Fluent to try it is hard to say. You might want to start fluent.exe using Process Monitor from SysInternals and watch for child processes being created. – Christian.K Jun 01 '11 at 08:41

2 Answers2

3

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.

Daniel B
  • 2,877
  • 18
  • 18
0

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

Saint
  • 5,397
  • 22
  • 63
  • 107