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". i am thinking to provide the answers from a text file. i have Created a text file with the answers
answers.txt
y
n
y
y
i have Created a another batch file called "wrapper.bat" file that runs install.bat 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 and how install.bat is taking input from answers.txt line by line ?
provide text file as an input to a batch file
Moderator: DosItHelp
-
- Posts: 33
- Joined: 01 Jan 2013 12:09
Re: provide text file as an input to a batch file
Which would work fine if you only needed one question answered.
You can stream in multiple lines by putting multiple set /p commands inside parentheses and redirecting the text file into the code block.
But personally I would create it more like and INI file. Then you could have a single FOR /F command set all the variables.
You can stream in multiple lines by putting multiple set /p commands inside parentheses and redirecting the text file into the code block.
But personally I would create it more like and INI file. Then you could have a single FOR /F command set all the variables.
Re: provide text file as an input to a batch file
So, let me get this straight…
You're asking the end user a series of questions, but instead of accepting their response you're forcing your own on them!
…so why bother asking in the first instance?
If you are accepting responses then think about using the CHOICE command's default response with timeout options.
You're asking the end user a series of questions, but instead of accepting their response you're forcing your own on them!
…so why bother asking in the first instance?
If you are accepting responses then think about using the CHOICE command's default response with timeout options.
Re: provide text file as an input to a batch file
Compo wrote:You're asking the end user a series of questions
The task looks to be to answer questions asked by the installer program.
I didn't follow it very well to begin with either.
Re: provide text file as an input to a batch file
sumant wrote:i have Created a another batch file called "wrapper.bat" file that runs install.bat 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
Yes, the code in your batch files.
We don't know what you are doing in them so any answer would be a random guess.