Reputation: 725
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.
Upvotes: 1
Views: 12276
Reputation: 94
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.
Upvotes: 3
Reputation: 267
You should either specify the full path or a relative path of the executable. Check this post for some examples.
Upvotes: 0
Reputation: 1690
Well, you may need to use a path relative to your unity build.exe's folder in order to make it work
Upvotes: 0