How to read input from console in a batch file?

后端 未结 3 1496
孤独总比滥情好
孤独总比滥情好 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:20

    If you're just quickly looking to keep a cmd instance open instead of exiting immediately, simply doing the following is enough

    set /p asd="Hit enter to continue"
    

    at the end of your script and it'll keep the window open.

    Note that this'll set asd as an environment variable, and can be replaced with anything else.

提交回复
热议问题