Running batch file from C # Force start from file directory?

So this is my ultimate goal. Steam allows you to add other installed games to your library, but only if it's the .exe file it pointed to to get started.

I just installed Arena and Daggerfall and they both run through DOSBox, which runs from a .bat file. So I decided to turn it into an .exe by writing my own. So far I have written the code. When I just run the .bat file it opens everything fine, however when I try to run it from my code the .bat file is executed but with errors. Here is my code below:

        if (File.Exists("D:\\Bethesda Softworks\\Arena\\Arena (Full Screen).bat"))
        {
            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe", "/c" + "\"D:\\Bethesda Softworks\\Arena\\Arena (Full Screen).bat\"");
            psi.RedirectStandardOutput = true;
            psi.UseShellExecute = false;

            System.Diagnostics.Process proc;
            proc = System.Diagnostics.Process.Start(psi);
        }

      

And the error I am getting is this: "The system cannot find the path specified." Dosbox.exe "is not recognized as an internal or external command, operating program, or batch file.

I'm not sure if this is an issue because of how dosbox is called from the Batch file or how the .exe ends up running the batch file. Anyway, I'd rather fix it in code rather than make changes to the .bat file itself.

Any help is greatly appreciated!

+3


source to share


1 answer


Try to set ProcessStartInfo.WorkingDirectory



psi.WorkingDirectory = "D:\\Bethesda Softworks\\Arena";

      

+5


source







All Articles