launch exe with params, but program closes instantly after opening?

Meta

I am writing a client for my gaming community and one of the functions of this client is to launch a game via the client with parameters that will enable our community mod pack on launch.

When I press the button, the game begins to launch and as soon as the program opens (the icon pops up in the task bar), it closes instantly.

Is there something I am missing that is needed to keep the launched exe running?

Here is my code:

private void btnLaunchGame_Click(object sender, EventArgs e)
    {
        string armaPath = gameDir+"/Expansion/beta/";
        string filename = Path.Combine(armaPath, "arma2oa.exe");
        string launchParams = "-noSplash -noFilePatching -showScriptErrors \"-name=Meta\" \"-mod=I:/Steam/steamapps/common/Arma 2;expansion;expansion/beta;expansion/beta/expansion;servermods/@HC_DAYZ;servermods/@HC_WEAPONS;servermods/@HC_EXTRAS;servermods/@HC_ACE\"";
        System.Diagnostics.Process.Start(filename, launchParams);
    }//close Game Launch

Any ideas is appreciated!

I have a .bat file that will execute the game flawlessly with the launch args listed below, this could possibly help pinpoint the cause of my problem: http://puu.sh/5CGKk.png (couldn't get code to paste in a readable format).

Sinatr

Try using Process:

        Process process = new Process();
        process.StartInfo.FileName = "arma2oa.exe";
        process.StartInfo.Arguments = "-noSplash -noFilePatching -showScriptErrors \"-name=Meta\" \"-mod=I:/Steam/steamapps/common/Arma 2;expansion;expansion/beta;expansion/beta/expansion;servermods/@HC_DAYZ;servermods/@HC_WEAPONS;servermods/@HC_EXTRAS;servermods/@HC_ACE\"";
        process.StartInfo.WorkingDirectory = gameDir + "/Expansion/beta/";
        process.Start();

It may be what exe require working directory to be set. Or it will crash, unable to load resources.

If that doesn't works, then perhaps you need to add

            process.WaitForInputIdle();

before exiting function running process. I don't know why, but running Acrobat Reader without this wait may sometimes cause a wierd effect: Acrobat is running, but the document, passed via arguments, is not shown. Perhaps something to do with Garbage collector or Process itself.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

.pyw tk program closes instantly?

From Dev

Simple desktop program instantly closes

From Dev

.exe closes immediately after launch when double clicked

From Dev

.exe closes immediately after launch when double clicked

From Dev

PyQt window closes after launch

From Dev

PyQt window closes after opening

From Dev

Win Form exe closes immediately after launch, deploying a win form application using setup project

From Dev

Google PlacePicker Closes Immediately After Launch

From Dev

Android Place Picker closes immediately after launch

From Dev

Facebook android shareDialog closes after opening

From Dev

PlacePicker.IntentBuilder closes immediately after opening

From Dev

Android app closes immediately after opening

From Dev

Cmd instantly closes

From Dev

opening an .exe after using Mingw

From Dev

Built exe closes after few seconds

From Dev

Launch program from commandline without .exe

From Dev

Filezilla program not opening after download

From Dev

Filezilla program not opening after download

From Dev

Program closes right after the last input

From Dev

opening a .exe (c program) from c#

From Dev

SDL OpenGL window instantly closes

From Dev

Python Executable File closes instantly

From Dev

Dropdown field automatically closes after opening in IE11

From Dev

'Workbook.open' error - Closes the file right after opening it

From Dev

Dropdown field automatically closes after opening in IE11

From Dev

AdMob AD view controller closes immediately after opening

From Dev

Kdevelop launch program after build execution

From Dev

Save document immediately after opening program

From Dev

How to stop AppleTV app from opening up after macOS launch?

Related Related

HotTag

Archive