我使用Inno Setup设计了我的安装程序,以显示2个组件供用户选择。根据他/她的选择,最后的Finish页面将显示Launch program复选框。如果已选择两个组件,则复选框的默认值为false。
到目前为止,非常好。
现在,我希望如果用户只选择其中一个组件进行安装,则复选框的默认值应为true。
以下是安装程序的“组件”和“运行”部分,
[Components]
Name: "Component1"; Description: "Component1"; Types: full;
Name: "Component2"; Description: "Component2"; Types: full custom;
[Run]
Filename: "{localappdata}\MyInstaller\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent unchecked; Components:Component1;
Filename: "{localappdata}\MyInstaller\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(TestAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent unchecked; Components:Component2
我理解我想要的东西,需要完成一些脚本。我不知道该怎么做。
请指导。
答案 0 :(得分:3)
Components
参数允许您使用布尔表达式运算符,因此对于您的情况,您可以编写两对条目,其中一个用于未选中复选框,第二个用于选中。你需要的其余部分是写一个表达式:
[Components]
Name: "Component1"; Description: "Component1";
Name: "Component2"; Description: "Component2";
[Run]
; this is the entry pair for unchecked check box; it is shown if both components
; are selected
Filename: "{app}\MyProg1.exe"; Flags: nowait postinstall skipifsilent unchecked; Components: Component1 and Component2;
Filename: "{app}\MyProg2.exe"; Flags: nowait postinstall skipifsilent unchecked; Components: Component1 and Component2;
; this is the entry pair for checked check box; it is shown only when the given
; component is selected and the other not
Filename: "{app}\MyProg1.exe"; Flags: nowait postinstall skipifsilent; Components: Component1 and not Component2;
Filename: "{app}\MyProg2.exe"; Flags: nowait postinstall skipifsilent; Components: Component2 and not Component1;
这会产生: