在静默模式下运行git bash for windows

时间:2017-11-01 12:03:43

标签: c# bash git-bash

我正在寻找一种在不显示终端窗口的情况下执行bash shell脚本的方法。我是从c#程序开始的。 ProcessStartInfo.CreateNoWindow属性对抑制打开bash终端没有影响。

Process process = new Process {
                StartInfo = new ProcessStartInfo {
                    FileName         = gitPath + "\\bash.exe",
                    Arguments        = "-c ./script.sh",
                    WorkingDirectory = Directory.GetCurrentDirectory(),
                    CreateNoWindow   = true} };

我希望这可能是bash中的一个参数?

1 个答案:

答案 0 :(得分:1)

WindowStyle = ProcessWindowStyle.Hidden可以解决问题!

Process process = new Process {
                StartInfo = new ProcessStartInfo {
                    FileName         = gitPath + "\\bash.exe",
                    Arguments        = "-c ./script.sh",
                    WorkingDirectory = Directory.GetCurrentDirectory(),
                    CreateNoWindow   = true,
                    WindowStyle      = ProcessWindowStyle.Hidden} };