0

I am trying to run an external .exe file with argument from unity, this what I have been doing:

ProcessStartInfo startInfo = new ProcessStartInfo("AAA.exe");
startInfo.WindowStyle = ProcessWindowStyle.Normal;      
startInfo.Arguments = "MyArgument";         
Process.Start(startInfo);

But an error keeps telling me that unity couldn't find the executable file. How can I add a path or make unity find the executable file? Advance Thanks.

Ran
  • 635
  • 2
  • 10
  • 22

3 Answers3

2

It appears you may be giving an incorrect Path to your .exe

Try something like this:

string fullPath = Path.Combine(Environment.CurrentDirectory, "/YourSubDirectory/yourprogram.exe");

ProcessStartInfo startInfo = new ProcessStartInfo(fullPath);
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.Arguments = "MyArgument";

Process.Start(startInfo);

Application Paths in Unity - Dependent on where your .exe is based, this may be of use.

Kieran Bond
  • 84
  • 1
  • 8
0

Well, you may need to use a path relative to your unity build.exe's folder in order to make it work

N.K
  • 1,601
  • 2
  • 19
  • 31
0

You should either specify the full path or a relative path of the executable. Check this post for some examples.

Arnaud VdP
  • 227
  • 1
  • 9