如何在c#中的控制台应用程序中在后台运行程序

时间:2011-10-03 19:56:36

标签: c# console batch-file

您好,我正在开发一个运行.bat文件的控制台应用程序,当程序启动时,它会弹出窗口中的主框,并且因为它每分钟运行几次,这可能会有点烦人我运行这个命令有什么办法......

System.Diagnostics.Process.Start(@"newmessage1.bat");

有没有办法让.bat cmd窗口以某种隐藏状态运行?

2 个答案:

答案 0 :(得分:1)

您可以使用CreateNoWindowUseShellExecute属性玩一下:

var psi = new ProcessStartInfo
{
    FileName = "newmessage1.bat",
    CreateNoWindow = true,
    UseShellExecute = false
};
Process.Start(psi);

答案 1 :(得分:1)

使用ProcessStartInfo.CreateNoWindow属性。

Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.FileName = @"newmessage1.bat";
myProcess.Start();