Processes lack permissions when opened through Unity?

I am trying to use Fairy-stockfish, a command line chess engine through Unity. This program needs to access a configuration ini for certain functions, and it does so just fine when opened through Windows explorer.

However, when the process is opened through the Unity file manager or in game through process.Start(), the application is unable to read the ini file. It’s even worse with fairymax (another command line chess engine), which won’t even open at all through Unity. Is there a workaround for this?

is it because its opening it in the current folder, not where the app is actually located?

I’m not sure, the app and the ini file are in Assets/plugins/Windows. I also put the ini in Assets and streamingassets for good measure, so I’m not sure where alse it would be working out of, especially since this happens when I’m just opening the app through Unity’s file explorer.

Specifying the full file path doesn’t seem to work either.

What’s the error you are getting?

Just double-clicking the .exe file you mean?
And the .exe is already in the same folder you try to run it in from Unity?

If so the most likely issue is an incorrect working directory. For the editor, the working directory will be the project root where the .sln and .csproj files are. For the build it’s the folder with the .exe. If the chess program is in a subfolder and you launch it with Process.Start you have to also set the working directory property for this process by using the path to the directory where the chess program is located.

Something like Application.dataPath + “/StreamingAssets/Chess” assuming its in StreamingAssets/Chess folder.

1 Like

You were absolutely right, it was operating out of the project root. Putting the ini there immediately fixed the problem both in editor and for the compiled game. THANK YOU!

1 Like

Yeah but maybe you don’t want to put the ini in the root. For the build at least this can be problematic. Who knows what else the cmd process is expecting to have within its own directory. Setting the working directory is the recommended course of action. :wink:

1 Like