我有一个C#程序;当我按下一个按钮时,我希望它打开一个CMD窗口,然后自动键入cmd窗口并运行该命令。到目前为止,我从4小时的研究中得到了这个。但没有任何效果。
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "cmd.exe";
//p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("ipconfig");
有关如何填写某个文本然后在按下按钮时自动运行它的想法吗?