Add checkbox in task Page In inno-setup and make it work according to checkbox

3.5k views Asked by At

How to add checkbox in task page in inno setup and make it work as checked or unchecked:

  • Install Visual C++

I have Tried-

  [Tasks] 
 Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons} 
 Name: vcredist_x64; Description: Install Visual C++; Flags: unchecked   
  [Code] 
 procedure CurStepChanged(CurStep: TSetupStep); 
 begin 
   if CurStep = ssPostInstall then 
   begin 
   var 
   ResultCode: Integer;
 begin
     if IsTaskSelected('vcredist_x64') then 
   begin 
       Status.Caption:='Installing Visual C++...';    
       Exec(ExpandConstant('{src}\Redist\vcredist_x64.exe'),'/q',false)

But it showing some error Identifier expected

I am very new to inno-setup and here (stackoverflow.com). Can anybody help me. Thanks in advance.

1

There are 1 answers

0
Kushal On BEST ANSWER

THIS IS THE ANSWER FOR MY QUESTION

Credit Goes To TLama

Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{49AA44CB-55C1-47D3-9B89-84D4A1271A8D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=Setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: english; MessagesFile: compiler:Default.isl
[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon};GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
Name: vcredist_x64; Description: Install Visual C++; Flags: unchecked

[Files]
Source: C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe; DestDir: {app}; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}
Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName};Tasks: desktopicon

[Run]
Filename: {src}\redist\vcredist_x64.exe; Parameters: /q; StatusMsg: Installing Visual C++...; Tasks: vcredist_x64