EXE run from unity does not work as it should.

I am attempting to run my own custom .exe from unity which I have managed to do. The .exe runs perfectly when I open it manually by double clicking, but from Unity it just opens then does not work at all.

For context, the .exe is a very basic script which reads a text file and then creates another one. When run from Unity the executable window says that this file does not exist, when I know it does, and then immediately closes.

I have tried running this .exe with these methods:

Application.OpenURL(path + "Search.exe");

and

Process.Start(path + "Search.exe");

and I have tried this with the .exe and the text file being in different places (Application.dataPath, Application.persistentDataPath, and also an external folder on my computer).

It seems no matter what I do the .exe just doesn’t run the same from Unity as when I click on it.

For anyone wondering, I found the solution was to set the Process’ directory to the path of the folder the .exe was in.

Specifically, this was the code I use:

Process process = new Process();
process.StartInfo.FileName = path + "Search.exe";
process.StartInfo.WorkingDirectory = path;
process.Start();