你如何在DOS输入一些提示编程? [英] How do you enter something at a DOS prompt Programmatically?

查看:103
本文介绍了你如何在DOS输入一些提示编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有程序,必须在DOS程序进行交互之前,我的程序可以继续它在做什么。我试图避免我的用户不必与本DOS程序进行交互。所以,我创建了一个.bat文件,做我需要的一切,除了最后一步,仍然需要我试图避免用户交互的事情。

I have program, that must interact with at DOS program before my program can continue what it is doing. I'm trying to avoid my user from having to interact with this dos program. So, I created a .bat file that does everything I need to do except for the last step which still requires user interaction that I'm trying to avoid.

具体来说,我键入命令在DOS提示符下,我需要自动输入y,然后输入(说是到提示符)结束了,然后我要退出了。

Specifically, the command I type ends up at a dos prompt where I need to automatically enter y and then enter (to say yes to the prompt) and then I want to exit out.

有什么办法,我可以使这个没有我的用户不必输入y和输入自动发生?理想情况下,我想有控制台窗口甚至没有弹出,而这是怎么回事。

Is there any way that I can make this happen automatically without my user having to enter y and enter? Ideally, I'd like to have the console-window NOT even pop up while this is going on.

推荐答案

您可以通过管道在'Y'字符到像这样的程序:

You can pipe in a 'y' character into the program like so:

echo y | executable.exe

多条线路可以像这样输入:

Multiple lines can be entered like so:

(echo y
echo n) | executable.exe

...这将通过第一个'Y',然后'N'。

...which will pass first 'y' then 'n'.

尖见这里。

这篇关于你如何在DOS输入一些提示编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆