如何使用Inno Setup安装程序为运行的批处理文件提供输入? [英] How to provide an input to a batch file ran using Inno Setup installer?

查看:61
本文介绍了如何使用Inno Setup安装程序为运行的批处理文件提供输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要安装我们的程序,我们需要运行批处理文件(安装整个应用程序),该批处理文件会提示用户一些问题,并以是/否"格式提供答案.我正在编写脚本,并在脚本中调用该批处理文件以安装整个程序.现在我想做的是在安装过程中隐藏控制台,并通过脚本提供所有答案.

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.

推荐答案

最简单的解决方案是修改批处理文件以执行您想要的操作,而无需询问.

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.

使用答案创建文本文件(例如 answers.txt ):

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

y
n
y
y

创建一个运行您的安装批处理的包装批处理文件,并从答案文件( wrapper.bat )重定向其输入:

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

安装所有文件,并让Inno Setup运行 wrapper.bat :

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

这篇关于如何使用Inno Setup安装程序为运行的批处理文件提供输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆