skr
skr

Reputation: 1811

How to provide input to batch file from a text file

I have a batch file(install.bat which i use to insatll my application) which prompts user with few questions like 'To accept licencse agreement click y/n'.So what i was thinking to provide the answers from a text file. i have Created a text file with the answers (e.g. answers.txt):

 y
 n
 y
 y

i have Created a wrapper batch file that runs my installation batch and redirects its input from the answers file (wrapper.bat):

@echo off
install.bat < answers.txt

is there any thing that i am missing beacuse its not working properly,i am not sure if install.bat taking some null values from the text file.

Upvotes: 0

Views: 1393

Answers (1)

Stephan
Stephan

Reputation: 56180

install.bat:

set /p a=Alpha
set /p b=Beta
set /p c=Gamma
set /p d=Delta
echo %a%,%b%,%c%,%d%

answers.txt:

a
b
c
d

call it like this:

install.bat<answers.txt

Upvotes: 1

Related Questions