3
如何从c#运行CMD而无需查看cmd窗口?如何从c#运行CMD与隐藏的CMD
如何从c#运行CMD而无需查看cmd窗口?如何从c#运行CMD与隐藏的CMD
在ProcessStartInfo
有一个名为CreateNoWindow
public static string ExecuteCommand(string command) {
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command)
{
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process proc = new Process())
{
proc.StartInfo = procStartInfo;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
if (string.IsNullOrEmpty(output))
output = proc.StandardError.ReadToEnd();
return output;
}
}
退房参数http://stackoverflow.com/questions/1096591/how-to-hide-cmd-window-while-running-a-batch-file - 与你想要做的非常相似 – InSane 2010-11-08 08:50:34