How to supply console input ( yes / no ) as part of batch file on Windows.

后端 未结 6 888
春和景丽
春和景丽 2020-12-08 08:33

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
         


        
6条回答
  •  庸人自扰
    2020-12-08 09:05

    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
    

    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.

提交回复
热议问题