# Something goes wrong when using System.Diagnostics.Process.Start to open a Monogame project

I am trying to develop a menu application for a homemade arcade. However, when I use Process.Start(path) to open my monogame projects' .exe files something weird occurs. If I try to open the .exe file manually it all works fine. When the menu opens one specific game all the effects disappear and in another the game crashes.

Other games on platforms such as Steam work just fine. From the beginning I thought that the Monogame projects somehow couldn't run at the same time. However, that is not the case as I tested running a MonoGame project from a basic terminal application. It had the same result as my menu.

Does anyone know why this could be occuring? Is there any equivalent to Process that does not have this issue?

• My guess would be that the game starts in the wrong working directory. Have you tried making sure the started process starts in the directory the executable is in? Jun 7 at 15:52
• Now after a closer examination I see that the path is in fact correct. The output from the console gave me this: "C:\Users\liopb\Desktop\Games\GravityWar\GravityWar.exe". The .exe file is in that exact folder. When I want to start the game I do Process.Start("C:\Users\liopb\Desktop\Games\GravityWar\GravityWar.exe"); Jun 7 at 16:48
• Nevermind! You said "Working Directory" so I looked it up. I had to set my ProcessStartInfo.WorkingDirectory to the folder that my .exe was in! Huge thanks! Jun 7 at 17:02

In order to solve the problem you have to set a so called working directory. This has to be the path to the folder in which the .exe is in.

My code:

ProcessStartInfo info = new ProcessStartInfo(path);

int index = path.LastIndexOf("\\") + 1;

string dirPath = path.Remove(index - 1);

info.WorkingDirectory = dirPath;
process = Process.Start(info);


Huge thanks to @Tyyppi_77 for pointing me in the right direction!