skr
skr

Reputation: 1801

How to provide an input to a batch file ran using Inno Setup installer?

To install our program we need to run batch file (which installs the whole application) which prompt user with few questions and we provide answer in "yes/no" format. I am writing a script and within the script I'm calling that batch file to install the whole program. Now what I am thinking to do is hide the console during installation and provide all the answers through the script.

Upvotes: 1

Views: 708

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202088

The simplest solution is to modify the batch file to do what you want it to do, without asking.


If you cannot do this (e.g. if the batch file is 3rd-party) you have to redirect its input from a text file.

Create a text file with the answers (e.g. answers.txt):

y
n
y
y

Create a wrapper batch file that runs your installation batch and redirects its input from the answers file (wrapper.bat):

@echo off
install.bat < answers.txt

Install all files and let Inno Setup run the wrapper.bat:

[Files]
Source: "install.bat"; DestDir: "{app}"
Source: "wrapper.bat"; DestDir: "{app}"
Source: "answers.txt"; DestDir: "{app}"

[Run]
Filename: "{app}\wrapper.bat"; Flags: runhidden

Upvotes: 1

Related Questions