Archive for the ‘Inno’ Category.

Containerize An Inno Installed Application

Introduction

In this article, we are going to create a Docker Image from an Inno Installer. The installer will install a .net 4.8 framework console application into the docker image.

Typically, when building docker images you should try to build the image from the source code but in the real world this is not always possible and in this article, we will assume that you do not have access to the source code for the installer or the console application that this being installed.

We will be using an installer called mysetup.exe, which installs an application called HelloWorldConsole.exe to the folder c:\program files (x86)\My Program\.

Containerize Procedure

In this procedure, we are going to create a Docker Image that will execute the installer and configure the container to run the application HelloWorldConsole.exe on startup.

  1. In the same folder as the installer mysetup.exe create a text file called Dockerfile.
  2. Using a text editor add the following code to the Dockerfile.
    FROM mcr.microsoft.com/dotnet/framework/runtime:4.8
    WORKDIR /app
    COPY mysetup.exe
    RUN mysetup.exe /VERYSILENT
    ENTRYPOINT ["/program files (x86)/My Program/HelloWorldConsole.exe"]
  3. Open the command prompt and navigate to the folder containing the Dockerfile and execute the command to create the docker image. The command will create a new docker image called installhelloworldconsole.
    docker image build --tag installhelloworldconsole .
  4. To create a container using the image run the command docker run. This command will create a container using the image created in the previous step and call the container hello2.
    docker run --name hello2 installhelloworldconsole
  5. After the container has booted, the container will execute the program c:\program files (x86)\My Program\HelloWorldConsole.exe
  6. You can confirm the program has been executed by checking the docker logs using the command docker logs and the name of the container.
    docker logs hello2

Summary

In this article, we create a docker container using a pre-existing installer.

Free Disk Space Inno

To show a label on the Inno wizard page displaying the amount of require disk space. Add the following code section to the installer script.

[Code]
procedure InitializeWizard;
begin
WizardForm.DiskSpaceLabel.Visible := True; // False to hide
end;

Download installer script FreeDiskSpace.iss

Check DotNet Framework is installed during Inno Setup

To check that DotNet framework is installed during an Inno install. Add the following code section to the install script.

; Check if dot net is insalled
[code]
function FrameworkIsNotInstalled: Boolean;
begin
Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\.NETFramework\policy\v4.0');
end;

// Install dot net with feedback
[Code]
procedure InstallFramework;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing .NET framework...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// you can interact with the user that the installation failed
MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;

In the files section add the dotnet installer file. Note the flags AfterInstall and Check that will call the functions to check if DotNet is installed and instal if required.

Source: "C:\Example\dotNetFx40_Full_x86_x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall; AfterInstall: InstallFramework; Check: FrameworkIsNotInstalled

Download the installer script CheckDotNet.iss

Mamadou Claquette hackeur ou fdp

vrm la wey c pa bien

CLIQUE CONCOMBRE DES MERS

Check if a program exists before installing with Inno

To check if a program exists before installing with Inno add the following code section to the installer script. In this example we will be testing for the file “c:\Example\Test.exe”. If the test.exe file exist a message box showing “Program Already Exists” will be displayed and the installer will terminate.

[Code]
function IsMyProgramInstalled: boolean;
begin
result := FileExists('C:\Example\Test.exe');
end;

function InitializeSetup: boolean;
begin
result := not IsMyProgramInstalled;
if not result then
MsgBox('Program Already Exists', mbError, MB_OK);
end;

Download the installer script IsMyProgramInstalled.iss

Create empty folders using Inno

When installing a program using Inno, to create an empty directory you will need to add a dirs section to the installer script.

[Dirs]
Name: "{app}\Example1"

Download installer script CreateEmptyDirectories.iss

Automatically Get Target Exe Version in Inno

This example shows how to automattically update the version numbers for you Inno installer based on the version number of the target exe program.

In this example the installer will be installing a program called notepad.exe.

At the top of the script. The version number from the target exe is stored in the variable MyAppVersion

#define MyAppVersion GetFileVersion("notepad.exe")

In the Setup section the MyAppVersion is used to set the installer version number, product version number and used as part of the installer name.

AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
OutputBaseFilename=Setup{#MyAppName}{#MyAppVersion}
VersionInfoVersion={#MyAppVersion}

Download the full installer code AutoGetVersionNumber.iss

Custom Inno Theme

To customise the look of your inno installer, you can modify the images displayed on the install pages. The large image on the left hand side of the instal pages is set using the parameter WizardImageFile. The small image shown on the top right of the install pages is set using the parameter WizardSmallImageFile.

In this example I have replaced the standard images with a large red image. Hopefully you will make an image that is more appealing.

InstallLargeImage

InstallSmallImage

The WizardImageFile and WizardSmallImageFile parameters should be defined in the [setup] section of the inno install script. In this example the images are in the folder c:\InstallFiles and are called Small.bmp and Large.bmp.


[Setup]
WizardSmallImageFile="C:\InstallFiles\Small.bmp"
WizardImageFile="c:\InstallFiles\Large.bmp"

The files must be saved as 256bit bmp files. I created my examples files using GIMP. To save the images using GIMP.

  1. Click File > Export As…
  2. Select a location for the file, enter a file name and then click export
  3. Expand the ‘Compatibility Options’ and check ‘Do not write color space information’. Expand the ‘Advanced Options’ and select 24 bits R8 G8 B8 and then click the export button
  4. Export

    The small image should be 55×58 pixels. The large image should be 164×314 pixels.

    Download full Inno script CustomImage.iss
    Download images Large.bmp Small.bmp

Installing Inno Installer

Detailed below is the procedure for installing Inno.

  • Download the setup file. I will be installing version 5.5.5 http://www.jrsoftware.org/download.php/is.exe
  • Select your language from the combo box and then click okinno1
  • Click the Next button on the welcome screen.inno2
  • Select Accept and then click the next buttoninno3
  • Change the install location if required and then click the next button.inno4
  • Change the start menu icon location if required and then click the next button.inno5
  • Click Next button to to install the preprocessor. inno6
  • Enable the additional settings if required and then click the next button.inno7
  • Click the install button to start the installation.inno8
  • Click the finish button to complete the install.inno9