我正在寻找一种在不显示终端窗口的情况下执行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中的一个参数?
答案 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} };