How to read input from console in a batch file?

后端 未结 3 1486
孤独总比滥情好
孤独总比滥情好 2020-12-04 20:49

How do I read input from the console in a batch file? What I am trying to achieve is the functionality of scanf in C. How can I do the same in a batch file?

3条回答
  •  旧巷少年郎
    2020-12-04 21:19

    In addition to the existing answer it is possible to set a default option as follows:

    echo off
    ECHO A current build of Test Harness exists.
    set delBuild=n
    set /p delBuild=Delete preexisting build [y/n] (default - %delBuild%)?:
    

    This allows users to simply hit "Enter" if they want to enter the default.

提交回复
热议问题