Archive for the ‘Inno’ Category.
May 11, 2023, 11:18 pm
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.
- In the same folder as the installer mysetup.exe create a text file called Dockerfile.
- 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"]
- 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 .
- 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
- After the container has booted, the container will execute the program c:\program files (x86)\My Program\HelloWorldConsole.exe
- 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.
February 23, 2015, 11:03 pm
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
February 23, 2015, 10:31 pm
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
February 23, 2015, 9:49 pm
February 23, 2015, 9:15 pm
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
February 23, 2015, 8:01 pm
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
February 18, 2015, 1:54 am
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
February 12, 2015, 10:32 pm
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.
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.
- Click File > Export As…
- Select a location for the file, enter a file name and then click export
- 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
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
January 5, 2015, 10:01 pm