小编win*_*nry的帖子

如何从 C# 执行 cygwin 命令并使其保持打开状态?

我正在尝试通过 C# 中的 bash 运行 cygwin 命令,并尝试使用 read 命令保持结果打开。我的代码似乎是打开 bash 然后立即关闭。我究竟做错了什么?

static void Main(string[] args)
{
    Process bashProcess = new Process();
    bashProcess.StartInfo.FileName = @"C:\cygwin64\bin\bash.exe";
    bashProcess.StartInfo.Arguments = "-l -c echo blah; read";
    bashProcess.StartInfo.UseShellExecute = true;
    bashProcess.Start();


    bashProcess.WaitForExit();
    System.Console.WriteLine("Exit Code: {0}", bashProcess.ExitCode);

    System.Console.WriteLine("Press enter to exit...");
    System.Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)

c# cygwin windows-console

5
推荐指数
1
解决办法
1861
查看次数

标签 统计

c# ×1

cygwin ×1

windows-console ×1