如何提供控制台输入(是/否)作为Windows批处理文件的一部分。 [英] How to supply console input ( yes / no ) as part of batch file on Windows.

查看:205
本文介绍了如何提供控制台输入(是/否)作为Windows批处理文件的一部分。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个简单的批处理文件(remove.bat)删除目录及其所有子目录。该文件包含以下命令 -

I am writing a simple batch file (remove.bat) to remove a directory and all its subdirectories. The file contains the following command-

rmdir /S modules

其中的模块的就是非空目录的名称。

where modules is the name of the non-empty directory.

我收到以下消息 -

I get the following message -

C:\...\bin>rmdir /S modules
modules, Are you sure (Y/N)?

我如何能提供的通过批处理文件控制台输入Y上述Y / N的问题?是否有一个命令可以做到这一点?

How can I supply through the batch file the console input "Y" to the Y/N question above? Is there a command that can do this?

推荐答案

正如其他人所指出的那样,你应该使用 / Q 选项。但还有另一种老派的方式做到这一点的是使用在当天返回的命令时,没有选择用晚餐preSS确认消息。简单地echo所需的响应和管道的价值到命令。

As others have pointed out, you should use the /Q option. But there is another "old school" way to do it that was used back in the day when commands did not have options to suppress confirmation messages. Simply ECHO the needed response and pipe the value into the command.

echo y|rmdir /s modules

我推荐使用 / Q 选项代替,但如果你曾经碰到一个命令,不提供一个选项,以燮$ P $管技术可能是重要的PSS确认消息。

I recommend using the /Q option instead, but the pipe technique might be important if you ever run into a command that does not provide an option to suppress confirmation messages.

这篇关于如何提供控制台输入(是/否)作为Windows批处理文件的一部分。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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