我想让他弹出框,并显示执行结果。 这段代码运行结果是弹出一个空的黑框,里面什么内容 也没有。这段代码问题出在哪?
ProcessStartInfo expressStartInfo = new ProcessStartInfo();
expressStartInfo.FileName = "cmd.exe";
expressStartInfo.Arguments = "ping "+ip; expressStartInfo.CreateNoWindow = false;
expressStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; expressStartInfo.RedirectStandardError = true;
expressStartInfo.RedirectStandardInput = true;
expressStartInfo.RedirectStandardOutput = true;
expressStartInfo.UseShellExecute = false;
using (Process expressProc = new Process())
{
expressProc.StartInfo = expressStartInfo;
try
{
expressProc.Start();
}
catch (Exception ex)
{
; } }
ProcessStartInfo expressStartInfo = new ProcessStartInfo();
expressStartInfo.FileName = "cmd.exe";
expressStartInfo.Arguments = "ping "+ip; expressStartInfo.CreateNoWindow = false;
expressStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; expressStartInfo.RedirectStandardError = true;
expressStartInfo.RedirectStandardInput = true;
expressStartInfo.RedirectStandardOutput = true;
expressStartInfo.UseShellExecute = false;
using (Process expressProc = new Process())
{
expressProc.StartInfo = expressStartInfo;
try
{
expressProc.Start();
}
catch (Exception ex)
{
; } }
expressStartInfo.RedirectStandardInput = true;
expressStartInfo.RedirectStandardOutput = true;
这3行去掉
expressStartInfo.Arguments = ip;