2011-10-03 61 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(); 
相關問題