简体   繁体   English

Process.Start不启动游戏应用程序?

[英]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. 我对C#来说还很陌生,我以前曾经弄过它,但是我真的很想现在就了解它。 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. 因此,我决定制作一个程序,用启动游戏时启动所有程序并在游戏关闭时关闭它们的程序替换launcher.exe。

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. 确切地说,该游戏是《生化奇兵2》,但我很可能会制作该程序,因此我可以将其与其他可以使用该程序的游戏一起使用。 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. 不过,这是我的问题,当我开始调试时,它将打开帮助游戏的程序之一(FlawlessWidescreen),但游戏本身无法打开。 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. 我已经尝试过仅运行BioShock2,但是它显示它很快运行然后关闭,没有错误,因此我无法确切地知道我在做什么错。

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. FlawlessWidescreen是一种快捷方式,我必须为其赋予提升的权限,因此我不必一直以管理员身份运行该应用程序。

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. 我也想知道你们中是否有人会知道如何检查BioShock2是否关闭,以便其他程序随之关闭。 Any ideas? 有任何想法吗?

Thanks 谢谢

Edit: I'd also like to add that another game I tried launched perfectly fine. 编辑:我还要补充一点,我尝试推出的另一款游戏非常好。

Fixed it by using the WorkingDirectory. 通过使用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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM