private void button1_Click(object sender, EventArgs e)
{
startDev(@"F:\\wifi.bat");
startDev(@"F:\\iperf.bat");
}
public static void startDev(string command)
{
Process cmd = new Process();
cmd.StartInfo.FileName = command;
cmd.StartInfo.UseShellExecute = true;
cmd.StartInfo.RedirectStandardInput = false;
cmd.StartInfo.RedirectStandardOutput = false;
cmd.StartInfo.CreateNoWindow = false;
//cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
cmd.Start();
//string ss = cmd.StandardOutput.ReadToEnd();
// cmd.WaitForExit();
//cmd.Close();
//return ss;
}
public static void startcmd(string command)
{
Process cmd = new Process();
cmd.StartInfo.FileName = command;
cmd.StartInfo.UseShellExecute = true;
cmd.StartInfo.RedirectStandardInput = false;
cmd.StartInfo.RedirectStandardOutput = false;
cmd.StartInfo.CreateNoWindow = false;
//cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
cmd.Start();
//string ss = cmd.StandardOutput.ReadToEnd();
//cmd.WaitForExit();
//cmd.Close();
//return ss;
}
就是上面这段代码,我放在winform里button事件中调用正常,如果放在console main函数里运行就会反复不断弹出cmd窗口。费解,求大婶帮忙看看
cmd.StartInfo.CreateNoWindow = false;
->
cmd.StartInfo.CreateNoWindow = true;
看看