Search code examples
inno-setuppascalscript

How to call Pascal Script procedure if user does not select a (desktop icon) task in Inno Setup


I want to create a setup with Inno Setup which run a procedure, if user doesn't check "Desktop icon" checkbox.

I want just run a procedure if this condition is true (so that this checkbox is unchecked).

Can you help me please ?

[Tasks]
Name: desktopicon; Description: "Create a &desktop icon"; \
    GroupDescription: "Additional icons:";  

[Icons]
Name: "{group}\iaca"; Filename: "{app}\iconApp.ico"
Name: "{userdesktop}\{#myAppName} ({#version})"; Filename: "{app}\{#myExeName}"; \
    IconFilename: "{app}\iconApp.ico"; Tasks: desktopicon

Solution

  • If you want to call your procedure during an installation, test a desktopicon task state using WizardIsTaskSelected support function in CurStepChanged event function.

    procedure CurStepChanged(CurStep: TSetupStep);
    begin
      if (CurStep = ssInstall) and (not WizardIsTaskSelected('desktopicon')) then
      begin
        Log('"Create a desktop icon" task was not selected.');
        { Call your procedure here }
      end;
    end;
    

    (The function is called IsTaskSelected in older versions of Inno Setup)