如何在 C# 中运行命令并从中检索数据?
可能的重复:
如何:在 C# 中执行命令行,获取标准输出结果
您好,
在我的 C# 应用程序中,我想从命令提示符运行命令并想要其输出并修改其输出。如果需要,想要关闭该进程并显示错误或适当的消息。要停止该进程,我必须在命令提示符下按“F4”键。直到该进程被停止或终止,它必须仅处于活动状态。
这怎么可能。非常感谢任何帮助。我坚持这一点并且会如果有人帮助我解决我的问题,我会很高兴,
谢谢。
Possible Duplicate:
How To: Execute command line in C#, get STD OUT results
Hello,
In my C# application, I want to run a Command from command promt and want its output and maipulate its output. If required, want to close the process and display error or appropriate message. To stop the process, I have to press "F4' key on command prompt. Till the process is stopeed or killed, it has to be alive only.
How is that possible. Any help is highly appreciated. I am stuck with this and would be glad if any body helps me solve my problem.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你需要这样的东西吗
Do you need something like this
试试这个:
http://msdn.microsoft.com/ en-us/library/system.diagnostics.process.standardoutput.aspx
但我不认为我们可以通过在命令行上按 F4 来停止命令的执行。
Try this:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx
But I don't think we can stop execution of the command by putting F4 on command line.
您可以尝试使用
System.Diagnostics
下的Process
来启动并获取输出您能否详细说明一下命令的类型及其意图,这部分不清楚
You may try using
Process
underSystem.Diagnostics
to launch and get the outputsCan you please elaborate on what type of commands and the intent of it, not clear on that part