为bat文件中存在的命令设置用户输入

时间:2021-12-28 02:05:55

I'm using command "rmdir" inside a bat file for some automation job. But, this command asks for some user input like remove all directory recursively or not. So, user need to provide set yes or no by typing "y" or "n"

我在bat文件中使用命令“rmdir”进行一些自动化工作。但是,此命令要求一些用户输入,如递归删除所有目录。因此,用户需要通过键入“y”或“n”来提供设置是或否

Can I set the user input inside my bat file??? So, that I don't have to enter the option manually each time I run that file.

我可以在我的bat文件中设置用户输入吗???因此,每次运行该文件时,我都不必手动输入选项。

NOTE: I have some other command which also needs user input. So I'm looking for a generalized solution.

注意:我还有一些其他命令也需要用户输入。所以我正在寻找一个通用的解决方案。

2 个解决方案

#1


A general solution is to echo the answer through a pipe, like:

一般的解决方案是通过管道回答答案,例如:

echo Y | rmdir /s myDir

#2


You could try to run rmdir /q. Source. It runs it in quiet mode.

你可以尝试运行rmdir / q。资源。它以安静模式运行。

#1


A general solution is to echo the answer through a pipe, like:

一般的解决方案是通过管道回答答案,例如:

echo Y | rmdir /s myDir

#2


You could try to run rmdir /q. Source. It runs it in quiet mode.

你可以尝试运行rmdir / q。资源。它以安静模式运行。