how to userinput without typing to a batch file

后端 未结 3 1544
面向向阳花
面向向阳花 2020-12-17 05:21

I am trying to run a batch file which requires user input \"y/n\" to do further action. I want to call this batch file for automation, as during automation argument yes or n

3条回答
  •  暖寄归人
    2020-12-17 05:37

    Use below command line to automate "yes" answer by simulating y key press (will include the ENTER key).

    cmd /c echo y^> "%temp%\answer.tmp" ^& (setup.bat ^< "%temp%\answer.tmp") ^& del "%temp%\answer.tmp"
    

    To automate "no" answer by simulating n key then ENTER` key.

    cmd /c echo n^> "%temp%\answer.tmp" ^& (setup.bat ^< "%temp%\answer.tmp") ^& del "%temp%\answer.tmp"
    

    To automate "yes" answer by simulating "yes" key presses then ENTER key:

    cmd /c echo yes^> "%temp%\answer.tmp" ^& (setup.bat ^< "%temp%\answer.tmp") ^& del "%temp%\answer.tmp"
    

    To automate "no" answer by simulating "no" key presses then ENTER key:

    cmd /c echo no^> "%temp%\answer.tmp" ^& (setup.bat ^< "%temp%\answer.tmp") ^& del "%temp%\answer.tmp"
    

提交回复
热议问题