Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup and Two conditions in Check

I'm writting a simple Inno Setup Script for my application. I did all the stuff I wanted but I'm blocked on something.

My app has two mode, Computer and Client that the user chooses at the start of the installation. If Client mode is picked, the application must start with windows. Also my app can be installed on both Windows version (32 and 64Bits), so not the same path for the registry key.

To make it start with windows, I added this at the end of my Inno setup script :

[Registry]
Check: IsWin64; Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; Permissions: users-full; ValueName: "MyApp"; ValueData: "{app}\AutoexecX86.cmd";

Check: Not IsWin64; Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; Permissions: users-full; ValueName: "MyApp"; ValueData: "{app}\Autoexec.cmd";

How can I add the condition that my app start only with the condition "Client mode is choosen". (ClientRadioButton.Checked)

like image 873
Alex Avatar asked Oct 30 '25 08:10

Alex


1 Answers

Check parameter documentation says:

Besides a single name, you may also use boolean expressions. See Components and Tasks parameters for examples of boolean expressions.

Components and Tasks parameters documentation says:

Besides space separated lists, you may also use boolean expressions as Components and Tasks parameters. Supported operators include not, and, and or. ...


So, add an auxiliary function like IsClientMode:

function IsClientMode: Boolean;
begin
  Result := ClientRadioButton.Checked;
end;

And combine it with your existing IsWin64 condition using and boolean operator:

[Registry]
Check: IsWin64 and IsClientMode; ...
Check: (not IsWin64) and IsClientMode; ...

Alternatively, particularly if the expression gets too complicated or when it is used frequently, you can factor it out to a separate function:

function IsClientModeOnWin64: Boolean;
begin
  Result := IsWin64 and IsClientMode;
end;
like image 152
Martin Prikryl Avatar answered Nov 02 '25 22:11

Martin Prikryl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!