[英]How to send keys to a process that started a bat file in C#?
This process starts a bat file that runs for a few seconds, after that I need to pass it a parameter for continue. 此过程将启动一个运行了几秒钟的bat文件,此后,我需要将其传递给参数以继续。
It is not possible to pass this parameter as an input parameter for the bat file. 不能将此参数作为bat文件的输入参数传递。
This is as far as I go 就我而言
ProcessStartInfo ProcessInfo;
Process Process;
ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
Process = Process.Start(ProcessInfo);
Now after a few seconds a menu is appearing and I have to input my choice to continue. 现在,几秒钟后出现一个菜单,我必须输入选择才能继续。
How can I do that? 我怎样才能做到这一点?
To send input to a process you use: Process.StandardInput 要将输入发送到流程,请使用:Process.StandardInput
See full documentation here: https://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput(v=vs.110).aspx 请参阅此处的完整文档: https : //msdn.microsoft.com/zh-cn/library/system.diagnostics.process.standardinput(v=vs.110).aspx
You could use WaitForInputIdle() if your process got a guid. 如果您的进程有向导,则可以使用WaitForInputIdle()。
Process.WaitForInputIdle();
Process.StandardInput.Write("Someinput");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.