ShadyOrb09 ShadyOrb09 - 3 months ago 19
C# Question

Process.Start Not Starting Game Application?

I'm pretty new to C#, I've messed around with it before but I really want to get to know it now.
I want to make an outside console application for a game, the game is a bad port and it requires a lot of programs to be open in the background to make it more playable. So I decided to make a program that replaces the launcher.exe with one that launches all the programs when the game starts and closes them when the game closes.

The game is BioShock 2 to be exact, but I'm most likely going to make this program so I can use it with other games that could make use of this program too.
Here's my problem though, when I start the debug it'll open up one of the programs to help the game (FlawlessWidescreen) but the game itself won't open.
I've tried just running BioShock2 but it shows it running for a quick second and then closes, no errors so I can't exactly figure out what I'm doing wrong.

Here's my code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Security;

namespace Bioshock2_Advanced_Launcher
{
public class SecurityException : SystemException
{
static void Main(string[] args)
{
Process.Start("F:\\Steam Library\\steamapps\\common\\BioShock 2\\SP\\Builds\\Binaries\\FlawlessWidescreen.lnk");
Process.Start("F:\\Steam Library\\steamapps\\common\\BioShock 2\\SP\\Builds\\Binaries\\Bioshock2.exe");
}
}
}


FlawlessWidescreen is a shortcut, I had to give it elevated permissions so I didn't have to run the application as an admin all the time.

I'd also like to know if any of you would know how to check if BioShock2 closes so the other programs will closes with it. Any ideas?

Thanks

Edit: I'd also like to add that another game I tried launched perfectly fine.

Answer

Fixed it by using the WorkingDirectory.

ProcessStartInfo bioshock2Info = new ProcessStartInfo();
bioshock2Info.FileName = (@"F:\Steam Library\steamapps\common\BioShock 2\SP\Builds\Binaries\Bioshock2.exe");
bioshock2Info.WorkingDirectory = Path.GetDirectoryName(@"F:\Steam Library\steamapps\common\BioShock 2\SP\Builds\Binaries\Bioshock2.exe");
Process bioshock2 = Process.Start(bioshock2Info);
Comments