2011-10-03 59 views
0

嗨那里我目前正在一个控制台应用程序运行的一个.bat文件,当程序启动它弹出作为我的窗口上的主框并且,因为这是运行好几次分钟,这样可以得到一点点讨厌的就是那里,当我运行此命令的任何方式......我如何使一个程序在c#中的控制台应用程序在后台运行#

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

在那里做的还挺运行.bat cmd窗口的方式隐藏状态?

回答

1

你可以围绕一个小播放使用CreateNoWindowUseShellExecute属性:

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

使用ProcessStartInfo.CreateNoWindow财产。

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