使用 Inno Setup 静默安装的默认组件

Default components for silent installation with Inno Setup

我正在 Inno 安装程序中开发安装文件。 当用户选择 'custom'.

时,它有 3 个不同的可选组件要安装

没问题,但传/SILENT参数时,没有安装任何组件。我想是因为没有检查组件。

...这里是相关的代码片段:

[Types]
Name: custom; Description: {cm:instCustom}; Flags: iscustom
Name: full; Description: {cm:instFull}

[Components]
Name: Programador; Description: {cm:cmpProgramador}; Types: full
Name: Usuario; Description: {cm:cmpUsuario}; Types: full
Name: Reporte; Description: {cm:cmpReporte}; Types: full

[Icons]
Name: {group}\{cm:cmpProgramador}; Filename: {app}\Programador\{#MyAppExeNameA}; Components: Programador
Name: {group}\{cm:cmpUsuario}; Filename: {app}\Usuario\{#MyAppExeNameB}; Components: Usuario
Name: {group}\{cm:cmpReporte}; Filename: {app}\Reporte\{#MyAppExeNameC}; Components: Reporte
Name: {group}\Desinstalar MIVES; Filename: {uninstallexe}

[Registry]
Root: HKCU; Subkey: Software\UPC; Flags: uninsdeletekey
Root: HKCU; Subkey: Software\UPC\MIVES
Root: HKLM; Subkey: Software\UPC; Flags: uninsdeletekey
Root: HKLM; Subkey: Software\UPC\MIVES
Root: HKLM; Subkey: Software\UPC\MIVES\Settings; ValueType: string; ValueName: InstallPath; ValueData: {app}

; file association depens of the components selected
Root: HKCR; Subkey: .mip; ValueType: string; ValueData: mip_auto_file; Flags: uninsdeletekey; Components: Programador
Root: HKCR; Subkey: mip_auto_file; Flags: uninsdeletekey; Components: Programador
Root: HKCR; Subkey: mip_auto_file\shell\open\command; ValueType: expandsz; ValueData: {app}\Programador\{#MyAppExeNameA} %1; Components: Programador

Root: HKCR; Subkey: .miu; ValueType: string; ValueData: miu_auto_file; Flags: uninsdeletekey; Components: Usuario
Root: HKCR; Subkey: miu_auto_file; Flags: uninsdeletekey; Components: Usuario
Root: HKCR; Subkey: miu_auto_file\shell\open\command; ValueType: expandsz; ValueData: {app}\Usuario\{#MyAppExeNameB} %1; Components: Usuario

Root: HKCR; Subkey: .mir; ValueType: string; ValueData: mir_auto_file; Flags: uninsdeletekey; Components: Reporte
Root: HKCR; Subkey: mir_auto_file; Flags: uninsdeletekey; Components: Reporte
Root: HKCR; Subkey: mir_auto_file\shell\open\command; ValueType: expandsz; ValueData: {app}\Reporte\{#MyAppExeNameC} %1; Components: Reporte

[Files]
Source: {#MyAppExeNameA}; DestDir: {app}\Programador; Flags: promptifolder; Components: Programador
Source: {#MyAppExeNameB}; DestDir: {app}\Usuario; Flags: promptifolder; Components: Usuario
Source: {#MyAppExeNameC}; DestDir: {app}\Reporte; Flags: promptifolder; Components: Reporte

我需要在传递 /silent/verysilent 参数时默认安装三个组件之一(组件 'Usuario')。

我想我必须使用 Check: WizardSilent,但我不知道在哪里。事实上,我尝试在 Components 部分添加 WizardSilent,但没有任何反应:

[Components]
Name: Programador; Description: {cm:cmpProgramador}; Types: full
Name: Usuario; Description: {cm:cmpUsuario}; Types: full; Check: WizardSilent

都不在 Files 部分:

[Files]
Source: {#MyAppExeNameB}; DestDir: {app}\Usuario; Flags: promptifolder; Components: Usuario; Check: WizardSilent

这是我需要的:

已编辑: 我想我找到了一种解决方案,但我不知道它是否是一个好的解决方案。刚刚添加了一种新类型,包括 WizardSilent 检查:

[Types]
Name: silent; Description: {cm:instCustom}; Check: WizardSilent
Name: custom; Description: {cm:instCustom}; Flags: iscustom
Name: full; Description: {cm:instFull}

并在组件部分使用它,组件"Usuario"(静默安装时我要默认安装的组件):

[Components]
Name: Programador; Description: {cm:cmpProgramador}; Types: full
Name: Usuario; Description: {cm:cmpUsuario}; Types: full silent
Name: Reporte; Description: {cm:cmpReporte}; Types: full

现在,它真的如我所愿。但我不喜欢有两种具有相同描述的类型,除非在设置向导中只显示一种。

这是个好主意吗?

谢谢!

我认为您的设置在概念上是错误的。

静默安装应该安装任何 typical/default/common 安装。现在看起来默认安装是 "Full" 安装,但您希望静默安装的行为有所不同。好像不太对。

所以您应该有一个默认的 "Typical" 安装类型,带有 "Usuario" 组件。就像你现在有 "Silent" 类型一样。但是 "Typical" 类型即使在交互式安装中也有意义。

[Types]
Name: typical; Description: "Typical"
Name: full; Description: "Full"
Name: custom; Description: "Custom"; Flags: iscustom

[Components]
Name: Programador; Description: "Programador"; Types: full
Name: Usuario; Description: "Usuario"; Types: full typical
Name: Reporte; Description: "Reporte"; Types: full

无论如何,/SILENT 应始终伴随 /LOADINF 或至少 /COMPONENTS/TYPE


您使用 "silent" 类型的解决方案虽然是 hack,但会在一定程度上起作用,因为 Check: WizardSilent 会在交互式安装中隐藏此类型。


顺便说一句,请注意,仅 /SILENT,在升级时,安装程​​序将使用在之前(可能是交互式)安装中选择的组件。