Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup: Disable postinstall checkbox with CLI flags

Tags:

inno-setup

I currently have the following in my [Run] section of an Inno Setup script

Filename: {app}\App.exe; Description: {cm:LaunchProgram,App}; Flags: nowait postinstall

For 99.9% of cases, this is perfect, the checkbox is ticked by default, and the application starts after a silent install (which we use for automatic updating), but there's always that one situation it's not.

Essentially, I need a way to disable/uncheck that option from command line in a silent install. I've tried using Tasks and Components but these add extra pages and checkboxes which I don't really want to appear.

A Task seems by far the easiest way to do this if there is a way to stop the checkbox appearing during a normal install, otherwise open to any ideas!

Cheers.

like image 622
Tram Avatar asked Mar 26 '26 10:03

Tram


1 Answers

I'm not sure about disabling or unchecking it, but you can completely remove it (or not) from the last page by using the "Check" parameter to call a script function.

[Run]
Filename: {app}\App.exe; Description: {cm:LaunchProgram,App}; Flags: nowait postinstall; Check: NoRunSwitch


[Code]
function NoRunSwitch: boolean;
var
  i: integer;
begin
  // Return TRUE to show the checkbox on the final page, return FALSE to hide it.
  Result := True; // In case there are no parameters
  for i := 1 to ParamCount do
  begin
    // Tweak the switch parsing to suit your needs here
    Result := not (UpperCase(ParamStr(i)) = '/NORUN');
    if not Result then break;
  end;
end;

Edit: After re-reading your message, I'm not sure but you may be asking how to do this for all silent installs? If you simply don't want this to happen during ANY silent install, you can just use the "skipifsilent" flag. If you meant you a silent install was only part of the condition, you can you use the Check method I described above, and you can use 'WizardSilent' in the check function to know if the installer is being executed in silent mode.

like image 76
Brad Stowers Avatar answered Mar 27 '26 22:03

Brad Stowers



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!