Controlling cmd.exe from Winforms

前端 未结 4 1764
面向向阳花
面向向阳花 2020-12-08 17:18

Question: I want to control cmd.exe from winforms.

I DO NOT mean every command in a single process, with startupinfo, and then stop.

I mean for example start

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 17:59

    You don't need to use cmd.exe for this, you can call the commands directly with Process.Start(). If you redirect StandardInput and StandardOutput you can control the process.

    I have written an example as a response to another question.

    Edit
    I don't have a complete example for it, but you could listen to StandardOutput with the Process.OutputDataReceived event if you don't want to wait synchronously. There is an example on the MSDN page.

提交回复
热议问题