在messagebox中查看cmd输出? [英] View cmd output in messagebox?
本文介绍了在messagebox中查看cmd输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到以下输出示例显示消息框怎么办?
Hi, I got the following output example displays a messagebox how to do?
System.Diagnostics.Process.Start("cmd.exe", "/c ipconfig -t");
推荐答案
这可能对你有所帮助开始了,
http://social.msdn.microsoft.com/Forums/is/csharplanguage/thread/7bd92d7d-15c0-4da5-a452-5c397437ecc7 [< a href =http://social.msdn.microsoft.com/Forums/is/csharplanguage/thread/7bd92d7d-15c0-4da5-a452-5c397437ecc7target =_ blanktitle =New Window> ^ ]
This might help get you started,
http://social.msdn.microsoft.com/Forums/is/csharplanguage/thread/7bd92d7d-15c0-4da5-a452-5c397437ecc7[^]
void MainForm_Load(object sender, EventArgs e)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c ipconfig";
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
StreamReader outputWriter = p.StandardOutput;
String errorReader = p.StandardError.ReadToEnd();
String line = outputWriter.ReadLine();
while (line != null)
{
Console.WriteLine(line);
line = outputWriter.ReadLine();
}
p.WaitForExit();
}
等一下。什么是命令行!
这一点显而易见,你绝对不需要CMD.EXE。这只是其中一个应用程序,没有别的,完全与你的问题无关。
你需要:
Wait a second. What a command line!
Isn''t this obvious that you absolutely don'' need CMD.EXE. This is just one of the applications, nothing else, totally unrelated to your problem.
You need:
System.Diagnostics.Process.Start("ipconfig", "-t");
哦!..
这篇关于在messagebox中查看cmd输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文