是否可以将安装程序命令行参数放在安装过程中调用的文件中? [英] Can I put setup command line parameters in a file which is called during installation instead?

查看:82
本文介绍了是否可以将安装程序命令行参数放在安装过程中调用的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建setup.exe之后,我必须将其打包以用于各种软件部署工具.因此,我无法使用参数调用setup.exe,而是将自己的参数放置在setup.exe旁边的setup.ini文件中.

After creating my setup.exe I have to pack it for various software deployment tools. Therefore I can't call the setup.exe with parameters, instead I have placed my own parameters in a setup.ini file next to the setup.exe

[Code]
var
    MyIniFile: String;
function InitializeSetup(): Boolean;
var
    LoadFromIniFile: String;
begin
    Result := true;
    MyIniFile := ExpandConstant('{srcexe}');      //writes the full path of the setup.exe in "MyIniFile"
    MyIniFile := Copy(MyIniFile, 1, Length(MyIniFile) - Length(ExtractFileExt(MyIniFile))) + '.ini'; //changes the ".exe" into ".ini"
    if FileExists(MyIniFile) then LoadFromIniFile := MyIniFile;  //checks wether there is a ini-file
    if LoadFromIniFile <> '' then begin
        MyLogFile := GetIniString('Setup', 'Log', MyLogFile , LoadFromIniFile);
        ProductName := GetIniString('Setup', 'ProductName', ProductName, LoadFromIniFile);
    end;
end;    

现在,我还要放置所谓的安装程序命令行参数"(在 Inno设置帮助站点).我认为/Dir="x:\dirname参数有一种方法,我还没有弄清楚.但是我也想在其中使用/SILENT参数,您认为有办法做到这一点吗?如果是,您将如何做?如果没有,您能给我提示为什么不这样做吗?

Now I want to also place the so called "Setup Command Line Parameters" (listed on the Inno Setup Help site) in my ini-file. I think that there is a way for the /Dir="x:\dirname parameter, which I did not figure out yet. But I also want to have the /SILENT parameter in there, do you think there is a way to do this? If yes, how would you do this? If not, can you please give me a hint why not?

推荐答案

因此,请针对不同的产品自定义安装程序,建议您使用预处理器,并自动为每个产品(具有不同的定义")构建安装程序,而不使用外部INI文件.

So customize your installer for different products, I'd recommend you to use a pre-processor and automatically build the installer for each product (with different "defines"), instead of using an external INI file.

例如,要在构建安装程序时能够更改应用程序名称和生成的可执行文件,请使用如下脚本:

For example to be able to change application name and resulting executable when building the installer, use a script like:

[Setup]
AppName={#AppName}
OutputBaseFilename={#BaseFilename}

现在,您可以使用命令行自动创建两个不同的安装程序:

Now you can create two different installers automatically using command-line:

ISCC.exe Example1.iss /dAppName=App1 /dBaseFilename=SetupApp1
ISCC.exe Example1.iss /dAppName=App2 /dBaseFilename=SetupApp2


关于隐式静默安装:


Regarding the implicit silent installation:

除了命令行/SILENT开关以外,没有其他API可以触发静默安装.

There's no API other than the command-line /SILENT switch to trigger silent installation.

但是您可以通过禁用大多数安装程序页面来创建近乎静默的安装:

But you can create a near-silent installation by disabling most installer pages:

[Setup]
DisableWelcomePage=true
DisableDirPage=true
DisableProgramGroupPage=true
DisableReadyPage=true
DisableFinishedPage=true

实际上,以上示例禁用了所有默认页面.但是,如果以前的所有其他页面均被禁用,则Inno Setup编译器将忽略DisableReadyPage=true.

Actually the above example disables all default pages. But Inno Setup compiler will ignore the DisableReadyPage=true, if all other previous pages are disabled.

您可能希望选择其他页面来显示.例如,欢迎页面(省略DisableWelcomePage=true,但保留DisableReadyPage=true).

You may want to choose a different page to show instead. For example a Welcome page (by omitting DisableWelcomePage=true, but keeping the DisableReadyPage=true).

如果您不介意使用外部文件(因为您已经在使用外部INI文件),则当然可以将安装程序包装为批处理文件,然后使用/SILENT开关调用安装程序.

If you do not mind about using external files (as you already use an external INI file), you can of course wrap the installer to a batch file and call the installer with the /SILENT switch.

这篇关于是否可以将安装程序命令行参数放在安装过程中调用的文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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