Creating a Windows application distribution in Inno Setup. Inno Setup Creating an installer

If you decide to start distributing your programs, then you cannot do without an installation distribution. Nowadays, almost all programs have an installer, usually called Setup.exe. In this article we will look at an example of how to build an installer for an Access application and look at some features that you need to know.

As mentioned earlier, Access does not allow you to make an executable file that can run without Access. But at the same time, Microsoft suggests using the Microsoft Office Developer package, which includes a license to distribute the program, to solve the problem Microsoft Access runtime. I will dwell on this in more detail.

Microsoft Access runtime is a version of Access that allows users to run, but not modify, an Access application. It only makes sense to install Microsoft Access runtime instead of the full version if you need licensing integrity, and the client running your database does not have an Access license. In this case, you will have to buy ODE (Office Developer Edition). Then, along with its purchase, you receive some additional tools and most importantly, the RIGHT to install for clients, along with the database you developed, also Run-time versions of Access. In this case, there will be no claims against the client regarding illegal use of Access. Otherwise, each client needs to buy an MS AAccess license.

The ODE package includes a “distribution creator” that includes your MDB and Run-time version in the distribution. All the libraries necessary for creating Run-time are already included in the full version of Access (even without ODE). But there is one BUT (this is for those who are concerned about licensing “cheat”):

If you do not buy it officially, then clients will still not have the right to use even the Run-time version.

The following thought may arise: What if you find out what files Access needs to work and include them in installation distribution? It is possible, but this does not solve the problem with the license. In addition, you will have to create a rather complex installation program with checking the existing components and installing/registering the missing ones. Moreover, in the latter case, it is possible to even destroy the system if performed ineptly.

In general, if we consider real situations with the sale of applications on Access, only a few developers ( we're talking about about Russia) actually buy license packages. As a rule, these are those for whom “at a certain level of business development, the question of whether to buy or not to buy loses its relevance” - or, more simply, who can afford to buy a license package for $600 - $1000. It’s interesting to then listen to them swear on forums about the operation of such programs. As far as I understand, there are the same “jambs” as in the pirated versions. Therefore, I will not urge you to use only free or pirated versions of Office for your programs, but I would not recommend using a licensed one either (see above).

Interestingly, the full version of Access can be launched in runtime mode by specifying the /runtime switch on the command line. For example, create a shortcut on the desktop, right-click on it, in the dialog box that appears in the object field, write something like this: (this is for Office 2000 - XP, but for 2003 you will need to fix it instead of Office10 - Office11)

"C:\ Program Files\Microsoft Office\Office10\MSACCESS.EXE" "D: \Bases\My Database.mdb"/runtime

and in the “Working folder” field:

Now let's launch the application through this shortcut. The Access project window will open, but the Access shortcut, as well as standard panels the tools will no longer be there. This is runtime mode.

For first-time developers, distributing Access applications through the Microsoft Office Developer suite may not be an option. After all, it costs money, and not little. We'll look at another method, using the free installer Inno Setup. Of course, there are others, both paid, for example InstallShield, and free installers. They differ in ease of use and the size of the distribution kit created.

Inno Setup is a freely distributed installer for Windows programs. English versions appeared back in 1997, now Inno Setup is translated into several languages, and installers can be created in more than 20 languages. Inno Setup is superior to many commercial installers in terms of features, stability, and size of the files it creates.

Key Features:

  • the program can compare file version information
  • move used files
  • register DLL/OCX/FNT/TLB and standard libraries
  • install fonts
  • checks whether certain programs are active
  • creating shortcuts for quick access (for example, through the start menu or on the desktop)
  • writing to ini files
  • built-in machine for writing scripts on Pascal language
  • supports multilingual installation
  • installation and uninstallation by default
  • all code is available (Borland Delphi 2.0-5.0)
  • password protection for setup
  • in case of cancellation during execution, all actions will be returned to their original state
  • supports all 32-bit versions of Windows (95, 98, 2000, 2003, XP, Me, NT 4.0)
  • creates the creation of one exe file, which greatly simplifies the installation process of your program
  • standard Windows 2000/XP interface
  • user-centric (e.g. full, minimal, custom)
  • all uninstallation tools
  • file installation: built-in support for "deflate", bzip2, 7-zip LZMA compression files

Also, starting from version 2.0.6 Inno Setup includes full support for MBCS. In more early versions the last property is not included. But it does not support Web installation.

The peculiarity of creating an installer in Inno Setup is that installers are created using scripts - simple ASCII text files reminiscent of .INI files. Scripts are easier to edit than, for example, working with the Installshield interface. Scripts have the extension ".iss" (inno setup script). It specifies all the installer parameters, and during installation, the program associates itself with these files. The script is divided into sections, the names of which are written in square brackets. Within sections there are keywords and instructions that the compiler can read and execute.

Comments begin with a semicolon at the beginning of a line and can be placed anywhere in the script. Comments in a block are not possible, as is placing a comment in the middle of a line. The latter is allowed by the compiler, but subsequently, when executed, leads to an error.

; -- Sample1.iss --
; Demonstrates copying 3 files and creating an icon.

The order of the sections does not matter. All of them (with the exception of ) are arbitrary. A keyword is assigned a value using an equal sign (=).

Hints consist of one or more parameters and their options, as well as flags. The parameter, in turn, consists of a name followed by a colon : and a value. Parameters, options, and flags are separated from each other by a semicolon;

Let's briefly look at the main sections:

Section

Meaning

contains instructions on the behavior of the installation routine, as well as how it should look. The AppName, AppVerName, and DefaultDirName keywords are required. All others - as needed
This contains the setup files
shortcuts (icons)
The ratio of components to the type of installation routine
allows you to create new empty folders
writes to INI files
the first action during installation, systax corresponds to the section
allows specific changes to the text
makes an entry in the register
executes other programs after the data has been successfully installed, but before the dialog box is closed
allows additional actions in setup
sets the setup type
last operation during uninstallation. This way the folders and/or files will be deleted
the first operation during uninstallation. Systax corresponds to section
contains information about the language. generally not used

Inno Setup works inside a script with various predefined constants, which usually contain paths. Way of writing: (name). Some constants such as (app) and (group) can/should be predefined by the user. Anyone who wants to define the constants themselves should turn to Alex Yackimoff's preprocessor.

Here are the main Inno Setup constants:

constant

example

(win) path to directory/folder Windows C:\Windows
(sys) path to the Windows system folder, specifically the System32 folder C:\Windows\System or C:\Windows\System32
(app) path to your own application (program)
(pf) path to program folder C:\Programme
(cf) path to shared data C:\Programme\Gemeinsame Dateien
(dao) corresponds to (cf)\Microsoft Shared\DAO C:\Programme\Gemeinsame Dateien\Microsoft Shared\DAO
(src) path to the installation routine folder at the time of setup R:\
(group) group of programs for the start menu

So, let's look at the problems that need to be solved (we'll define only the minimal ones). Our installer should do the following:

Unzip files to required locations
Create a folder in the program directory (folder “Cop” - for storing database backups)
Create an application launch menu in Start - All Programs, as well as an icon on the desktop

This minimum required. But, of course, this is not all the possibilities of Inno Setup. It’s not for nothing that many developers use it. But in this article I will limit myself to only this; those who wish to study the program’s capabilities in more depth can refer to help system. There are many links on the Internet both to the program and to translations of the help. For example, Inno Setup 5.1.6. and the help for it you can download here... English website of the program http://www.innosetup.com

First, try experimenting by creating an installer using the wizard, and then studying the structure of the resulting script. In principle, I think there is no need to describe in detail what to press where. Inno Setup is so easy to learn that it can be learned without any problems, which is called the “scientific poking method.” Here, for example, is an installer script that performs previously defined tasks (all distribution files are located in the D:\Setup directory.)


AppName=My program
AppVerName=My program. Version 1.0.
AppPublisher=MyProgram, Inc.
AppPublisherURL=http://MyMySoft.ru/
AppSupportURL=http://MyMySoft.ru/
AppUpdatesURL=http://MyMySoft.ru/
DefaultDirName=(pf)\MyProgram
DisableDirPage=no
DefaultGroupName=My program
DisableProgramGroupPage=yes
LicenseFile=D:\Setup\license.txt
InfoAfterFile=D:\Setup\readme.txt
AlwaysCreateUninstallIcon=yes


Name: "desktopicon"; Description: "Create a shortcut on &Desktop"; GroupDescription: "More shortcuts:"


Source: "D:\Setup\Server.mdb"; DestDir: "(app)"; DestName: "Server.mdb";
Source: "D:\Setup\license.txt"; DestDir: "(app)";
Source: "D:\Setup\readme.txt"; DestDir: "(app)";
Source: "D:\Setup\Log.JPG"; DestDir: "(app)";
Source: "D:\Setup\Log.ico"; DestDir: "(app)";
Source: "D:\Setup\Base.mdb"; DestDir: "(app)";


Filename: "(app)\MyProg.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://MyMySoft.ru/"


Name: "(app)\Cop"


Name: "(group)\My program"; Filename: "(app)\Base.mdb" ;WorkingDir: "(app)";IconFilename:(app)\Log.ico
Name: "(group)\Program website"; Filename: "(app)\MyProg.url"
Name: "(userdesktop)\My program"; Filename: "(app)\Base.mdb" ;WorkingDir: "(app)"; IconFilename:(app)\Log.ico;Tasks: desktopicon

You can download an example of how it all works below.

  • Contact "Interface" for additional information/on purchasing products

Downloads

You have written an excellent program and all you have to do is create an original and decent installer for it, so that the user can easily and simply install your application on their computer in a few clicks? How to make an installer software? Meet - free program, helping to create a high-quality installer for application, working in the environment operating system Windows. The result of the work There will be a single EXE program installer. Utility has ample opportunities to create installation file programs, in some cases significantly superior in functionality to commercial products for creating software packages. Program includes a wizard for creating an installation package ( wizard), thanks to which you can quickly and easily create a distribution package of the program.

Creating a distribution

Inno Setup is easy to set up, has a clear script structure, supports encryption, scripts in the language Pascal, setting a password, reading from and writing to the registry, setting tasks to be performed after installation is complete. The installation type option allows you to create options such as full, minimal or custom installation with a custom set. Inno Setup supports the creation of multilingual software distributions. All characteristics and settings of the future program installer are stored in a script (installation script), which must be compiled after it is written. The program includes ready-made examples of scripts aimed at various tasks, which the created distribution will execute.


Installer script

Installer script this is a regular text file with the extension INI divided into sections (section names are in square brackets: , , , etc.). The script contains all the necessary options and settings for the created distribution, such as information about the author, name and version of the program, application files, installation directory, and others. If you don’t have enough distribution creation wizard or don’t have time to study the parameters and section constants, there are a large number of ready-made scripts for Inno Setup on the Internet.


Installation packages created by the Inno Setup program work without failures, are decently designed and implement everything necessary requirements to install software. Inno Setup is professional, competent, free and reliable any programmer's tool. The archive offered for download contains a help file translated into Russian (help) programs

Official website: http://www.jrsoftware.org
Operating systems: Windows All
Supported languages: English
Version: 5.4.2 (a)
License: freeware (for free)

File size 1.79 MB

To make it easier to install your programs on users' computers, you will need to create a distribution kit. Today I want to talk about a very powerful and free tool to create distribution kits for Windows OS - Inno Setup.

About Inno Setup

Inno Setup, which appeared in 1997, today competes with paid installers and even surpasses many of them in terms of the number of functions and stability. The project home page is located.

Here key features installer:

      • Support for everyone Windows versions starting from Windows 2000, including: Windows 8, Windows Server 2012, Windows 7, Windows Server 2008 R2, Windows Vista, Windows Server 2008, Windows XP, Windows Server 2003 and Windows 2000. In this case, no update packages are required.
      • Extensive support for installing 64-bit applications on 64-bit versions of Windows. Support for x64 and Itanium architectures (if you are using Windows Server 2003 on Itanium architecture, Service Pack 1 or later is required to install 64-bit mode).
      • The ability to create a distribution kit consisting of one single EXE file for easy distribution on the Internet. Disk partitioning is also supported.
      • Standard installation wizard interface Windows style 2000/XP.
      • Customizable installation types such as Full, Compact, Custom.
      • Wide range of uninstallation options.
      • File installation: Includes integrated support for deflate, bzip2 and 7-Zip LZMA/LZMA2 compression. The installer can compare file versions, replace used files, use counting shared files, register DLL/OCX and type libraries, and install fonts.
      • Create shortcuts anywhere, including the Start menu and desktop.
      • Creating registry items and INI files.
      • Run other programs before, during, and after installation.
      • Creation of multilingual distributions, including left-to-right languages.
      • Creation of password-protected and encrypted distributions.
      • Support digital signature during installation and removal.
      • Hidden installation and removal.
      • Unicode support.
      • Built-in preprocessor for additional customization during compilation.
      • Built-in Pascal script engine to perform additional actions during installation and uninstallation.
      • Free source code (Borland Delphi 2.0-5.0 and 2009).

The big advantage of Inno Setup is that it is absolutely free to use, even for commercial use. Although, as a thank you or to support the installer, you can make a donation. There is also a list of everyone who donated $100 or more.

This is what it looks like home page standard distribution installation wizard created using Inno Setup.

About creating a distribution in Inno Setup

Creating a distribution using Inno Setup proceeds as follows:

1. First you create an Inno Setup script. The Inno Setup script is a text file with the extension .iss, which contains the properties of the distribution and a set of actions performed during installation and removal. The script can be created using standard editor Inno Setup (see picture) or using one of the third-party editors such as Inno Script Studio or ISTool. In this article I will only cover using the standard Inno Setup editor.

2. Then you compile the script, resulting in a distribution.
3. After compilation, you can test and debug the resulting distribution, performing installation and uninstallation.

Installing Inno Setup

To create distributions using Inno Setup, you just need to install the Inno Setup compiler on your computer. The distribution can be downloaded. Latest download link stable version you can find it in the Stable Release section. At the time of writing latest version Inno Setup was 5.5.5, see picture. To download the distribution, click on the link “Random site" next to the version with Unicode support (file isetup-5.5.5-unicode.exe) or without it (ANSI version - file isetup-5.5.5.exe). To avoid problems with displaying the Cyrillic alphabet, it is better to immediately use the Unicode option Inno Setup.

If you are going to encrypt your future distribution, then you need to download the ISCrypt.dll encryption module separately in the Encryption Module section, see the picture (below you see a link to source codes of this module – ISCrypt.zip ).

On the same page in the QuickStart Pack section you can find a link to the distribution kits ispack-5.5.5.exe and ispack-5.5.5-unicode.exe for installing Inno Setup along with Inno Script Studio, see the picture. Inno Script Studio is a third-party development (Kymoto Solutions) that offers you its user-friendly interface and the ability to debug your installer at runtime. Also, this distribution will offer to download and install the ISCrypt.dll encryption module automatically.

In addition to all of the above, on the download page there are sections Beta Release, for downloading beta versions of Inno Setup, and for downloading source codes, which I will not focus on.

If you are going to use more advanced Inno Setup script editors, then you will also be interested in the Inno Setup Third-Party Files page with a list of third-party developments. Here are the third-party developments we can use in conjunction with Inno Setup:

      • Inno Script Studio - user interface and debugger. Installed using the QuickStart Pack distribution (see above) or a separate distribution that you can download from the developer’s website. There is Russification.

      • Visual & Installer is a paid plugin for Visual Studio(supported by Visual Studio 2005, 2008, 2010, 2012 and 2013) to create distributions using Inno Setup. Visual & Installer also contains a Graphical Installer Wizard, which allows you to create thematically designed distributions (see examples).

    • Inno Download Plugin is a library and Inno Setup script that makes it possible to download files during the installation of your distribution. There is support for the Russian language. FTP, HTTP and HTTPS protocols are supported.

      • InnoTools Downloader is another option, similar to Inno Download Plugin, also for downloading files during installation. But there is no localization here, and only FTP and HTTP are supported.
      • VCL Styles for Inno Setup / ISSkin / Graphical Installer (the latter tool is paid) - tools for changing the design of the installation wizard of your distribution.

      • InnoScript - automatically creates an Inno Setup script file (.iss) from the project file Visual Basic(.vbp or .vbproj). There is Russification.

      • – creates a distribution kit for a Visual Basic project from the Visual Basic 6.0 development environment.

      • – allows you to use a Delphi project file (.dpr) or a Delphi library project file (.dpk) to create a list of dependencies necessary for creating a distribution. This utility refused to work for me with the Delphi XE3 project.
      • Inno Setup Script #Includes - a library of functions that you can use during installation. The list of functions can be viewed.
      • Inno Setup Easy Translator is an editor for Inno Setup language files (.isl). This site has been down since 2013, but there is no need to worry because you can easily create and edit language files in any text editor.
      • UninsHs is an extension that allows you to add Repair/Modify/Remove support to your applications.

Also in this list, for some reason, there are still some well-known developments (list updated 04/13/2015):

      • – user interface for working with the Inno Setup script. This program is very similar to Inno Script Studio. If you search, you can find Russification, see picture.

      • InnoIDE is another user interface for working with the Inno Setup script. The InnoIDE website ceased to exist around August 2012 (www.innoide.org), so there is no point in using this development. But the archive of the site has been preserved, which can be viewed. You can also download the distribution there. Russification for InnoIDE can be found on the Internet.

      • InnoSetup Script Joiner is a utility that combines several Inno Setup scripts into one.
      • (Inno Setup Unpacker) - unpacker of distributions created using Inno Setup. Console application.
      • InnoExtractor is another unpacker, but it has a user interface. There is Russification. It worked perfectly with my encrypted test distribution (see picture). As you can see, it gets absolutely all the files, including the files used by the installer, and even the Inno Setup script file.

Actually, after you have decided on the necessary functionality, you can begin the installation. Here I will only look at installing Inno Setup + Inno Script Studio using the QuickStart Pack (file ispack-5.5.5-unicode.exe). Although there is no point in describing all the steps in detail, I will focus only on a few. The “Download and install Inno Script Studio" checkbox should be checked if you want to install Inno Script Studio, the "Install Inno Setup Preprocessor" checkbox - to install the preprocessor, the "Download and install encryption support" checkbox - to install the ISCrypt.dll module to encrypt the distribution. .

First launch of Inno Setup Compiler

The only window of the Inno Setup program is the compiler window. The compiler is launched from the Start menu. When you first launch it, you will see a prompt asking you to create an empty script, run the Create Script Wizard, or open examples or recently used files.

If you have no experience with Inno Setup, then examples will be helpful. Let's open an example, click the "OK" button and select one of the examples. After the example has opened, you can evaluate what a simple Inno Setup script looks like. Also note that the compiler interface is very simple and you will need to write the entire script manually. You will only have reference and examples at your disposal here.

Using the Wizard to Create an Inno Setup Script

You can create a new Inno Setup script from scratch or you can use the Script Wizard. For example, I will make a distribution kit for installing the program MyProg.exe, which is located in the folder with examples (installed with Inno Setup). When launched, the program displays two windows and exits.

To open the script creation wizard window, click on the menu item “File -> New" Or in the welcome window, select the option "Create a new script file using the Scrip Wizard" and click "OK". The first screen of the wizard will be a welcome message. Click here "Next >".

On the second screen, enter the Application name, Application version, Application publisher, and Application website. Required fields are marked in bold in the wizard, while the rest can be left blank.

In the next step, you select a folder for your application. By default, as you can see from the picture, this is a folder with the same name as the application name, and it will be created inside the Program Files folder. The “Allow user to change the application folder” checkbox will allow the user to change the folder during the installation process. And when you check the “The Application doesn’t need a folder” checkbox, the application folder will not be created at all.

If you select “(Custom)” from the “Application destination base folder” drop-down list, then in the field just below you can set an arbitrary path. For example, to have your application folder on the system drive, you need to specify “(sd)”.

As you can see, to indicate the system drive I specified “(sd)” instead of “C:”, because on different computers system disk may be different. In general, in Inno Setup you will use constants like “(sd)” very often. All constants are surrounded by curly braces and there are a lot of them. Here is the complete list of constants with brief description(for a full description, see the “Constants” section in the help):

Directory constants:

      • (app) – application directory, for example, “C:\Porgram Files\My Program”.
      • (win) – Windows directory, for example, “C:\WINDOWS”.
      • (sys) – System32 directory, for example, “C:\WINDOWS\SYSTEM”.
      • (src) – the directory in which the distribution files are located (this is a temporary folder with unpacked distribution files).
      • (sd) – system drive, for example, “C:”.
      • (pf) – application directory, for example, “C:\Program Files (x86)” (in 64-bit mode, this will be the folder for 64-bit applications). In 32-bit mode this constant is equivalent to the constant (pf32) , and in 64-bit mode it is equivalent to (pf64) .
      • (cf) – common files folder, for example, “C:\Program Files (x86)\Common Files”. In 32-bit mode this constant is equivalent to the constant (cf32) , and in 64-bit mode it is equivalent to (cf64) .
      • (tmp) – temporary folder used during installation or uninstallation (the folder name will be in the format “C:\WINDOWS\TEMP\IS-xxxxx.tmp”).
      • (fonts) – fonts folder.
      • (dotnet11) – .NET Framework 1.0 root folder.
      • (dotnet20) – .NET Framework 2.0 root folder. In 32-bit mode this constant is equivalent to the constant (dotnet2032) , and in 64-bit mode it is equivalent to (dotnet2064) .
      • (dotnet40) – .NET Framework 4.0 root folder. In 32-bit mode this constant is equivalent to the constant (dotnet4032) , and in 64-bit mode it is equivalent to (dotnet4064) .

Environment folder constants:

      • (group) – path to the Start menu folder, accessible to all users.
      • (localappdata) – path to local (without roaming) Application folder Data.
      • (sendto) – path to the user’s Send To folder.
      • (userappdata) and (commonappdata) – path to the Application Data folder.
      • (usercf) – path to the user’s Common Files folder (works only for Windows 7 and later versions; for older versions of Windows, this constant will be equal to (localappdata)\Programs\Common).
      • (userdesktop) and (commondesktop) * - path to the desktop folder.
      • (userdocs) and (commondocs) – path to the My Documents folder.
      • (userfavorites) and (commonfavorites) * - path to the Favorites folder.
      • (userpf) – path to the user’s Program Files folder (works only for Windows 7 and later versions; for older versions of Windows this constant will be equal to (localappdata)\Programs).
      • (userprograms) and (commonprograms) * - path to the “All Programs” folder in the “Start” menu.
      • (userstartmenu) and (commonstartmenu) * - path to upper level Start menu.
      • (userstartup) and (commonstartup) * - path to the Startup folder in the Start menu.
      • (usertemplates) and (commontemplates) * - path to the “Templates” folder.

* = "common" constants are equal to "user" constants if the user lacks administrative privileges or the PrivilegesRequired statement is set to lowest.

Other constants:

      • (\) – used in cases where you need to install a slash at the end of the path, for example, (app)(\). Otherwise, Inno Setup will remove the last slash.
      • (%NAME|DefaultValue) – the value of the environment variable, where NAME is the name of the variable, DefaultValue is the string to be used if the variable does not exist. DefaultValue – optional. Examples: (%COMSPEC) or (%PROMPT|$P$G). If the line uses the characters “,”, “|”, “)” or “%”, then instead of them you need to write “%2c”, “%7c”, “%7d” and “%25”, respectively.
      • (cmd) – the full path to the console, for example, Windows\System32\cmd.exe (the COMSPEC environment variable is not used to expand this constant).
      • (computername) – the name of the computer on which installation or uninstallation is performed (the value returned by the GetComputerName function).
      • (drive:Path) – Gets the drive letter followed by a colon from an arbitrary path. If a UNC path is specified, it returns the server and folder, for example, \\SERVER\SHARE. Here too, to write the characters “,”, “|”, “)” or “%”, you need to write “%2c”, “%7c”, “%7d” and “%25”, respectively. Here are examples: (drive:(src)), (drive:c:\path\file) or (drive:\\server\share\path\file).
      • (groupname) – the name of the folder in the Start menu for your menu items that the user selected during installation. Unlike the constant (group), it returns only the name, not the full path.
      • (hwnd) – identifier of the installer background window.
      • (wizardhwnd) – identifier of the installer wizard window or 0 if the identifier is not available.
      • (ini:Filename,Section,Key|DefaultValue) – value from the INI file, where Filename is the name of the INI file, Section is the name of the section in the INI file, Key is the name of the key in the INI file, DefaultValue is the string you need use if the specified key is not found. Here too, to write the characters “,”, “|”, “)” or “%”, you need to write “%2c”, “%7c”, “%7d” and “%25”, respectively. Example: (ini:(win)\MyProg.ini,Settings,Path|(pf)\My Program).
      • (language) – internal name of the selected language.
      • (cm:MessageName) and (cm:MessageName,Arguments) – message in the current language, where MessageName – message name, Arguments – arguments for the message, separated by commas. Here too, to write the characters “,”, “|”, “)” or “%”, you need to write “%2c”, “%7c”, “%7d” and “%25”, respectively. Example: (cm:LaunchProgram,Inno Setup).
      • (reg:HKxx\SubkeyName,ValueName|DefaultValue) – a string from the registry, where HKxx is the root registry key, SubkeyName is the path to the right key, ValueName – the name of the value (or empty if you need to read the default value for the key), DefaultValue – the string that should be used if there is no specified value or the value is not a string (REG_SZ or REG_EXPAND_SZ). Here too, to write the characters “,”, “|”, “)” or “%”, you need to write “%2c”, “%7c”, “%7d” and “%25”, respectively. Example: (reg:HKLM\Software\My Program,Path|(pf)\My Program).
      • (param:ParamName|DefaultValue) – parameter passed to the installer on the command line, where ParamName is the name of the parameter, DefaultValue is the string to be used if specified parameter not found. Here, to write the characters “,”, “|”, “)” or “%”, you need to write “%2c”, “%7c”, “%7d” and “%25”, respectively. Example: (param:Path|(pf)\My Program).
      • (srcexe) – full path to the installer, for example, C:\SETUP.EXE.
      • (uninstallexe) – full path to the uninstaller created by the installer, for example, C:\Program Files\My Program\unins000.exe. This constant is typically used to create a shortcut for uninstalling a program in the Inoo Setup script section. The constant is only valid if the Uninstallable statement is set to yes.
      • (sysuserinfoname), (sysuserinfoorg) – the name and organization, respectively, under which Windows is registered. This information is read from the registry.
      • (userinfoname) , (userinfoorg) , (userinfoserial) – the name, organization and serial number, respectively, specified by the user on the “User Information” page in the installer wizard (which can be enabled using the UserInfoPage instruction). Typically this information is used to write to the registry or INI for later use.
      • (username) – the name of the user who launched the installer or uninstaller (the GetUserName function is used).
      • (log) – name of the log file or an empty string if logging is not enabled.

The next step of the Inno Setup Script Wizard allows you to add your application files.

In the topmost field, the main executable file is selected. If you check the box “Allow user to start the application after Setup has finished”, then the user will see a proposal to start the application after installation. If your distribution does not have an executable file, then you can check the box “The application doesn’t have a main executable file”. Below is a list of files for your distribution. Here you can add separate files(button “Add file(s)…”) or entire folders (button “Add folder…”). When adding a folder you will see additional question whether to include subfolders or not.

After adding folders and files to the list, you will be able to edit each item ("Edit..." button) or delete it ("Remove" button). In the editing window, you can change many parameters: whether you need to recursively include subfolders (checkbox " Recurse subfolders"), whether you need to include empty folders ( checkbox " Include empty subfolders"), the destination base folder (fields " Destination base folder") and the folder inside base destination folder (“Destination subfolder”).

We will only add a help file as an example.

The next step of the wizard is to select the icons to be created. In the "Application" field Start Menu folder name" sets the name of the group in the Start menu. If you check the box “Allow user to change the Start Menu folder name”, then the user will be able to change the name of the folder during installation, and if you check the box “Allow user to disable Start Menu folder creation”, then the user will be able to disable the creation of this folder altogether in the Start menu. Check the box “Create an Internet shortcut in the Start Menu folder” and “Create an Uninstall icon in the Start Menu folder” so that the installer creates shortcuts within the group, respectively, for opening your site and for uninstalling your application. The “Allow user to create a desktop icon” and “Allow user to create a Quick Launch icon” checkboxes will allow the user to create shortcuts on the desktop and in the group quick launch. I'll check all the boxes.

The next step is to set up the license files and information files that will be displayed before and after installation. If you specified a license file, then during installation the user will have to agree to the license. .txt and .rtf files are supported. I will specify the license.txt and Readme.txt files from the examples folder.

In the next step, select supported languages. I'll leave English and add Russian.

The next step is to set the parameters for the Inno Setup compiler. In the “Custom compiler output folder” field, specify the path to the folder in which the Inno Setup compiler will save the created distribution. If this field is empty, the distribution will be created in the same folder as the .iss file. The “Compiler output base file name” field specifies the base name for the distribution file or files. For example, if you set the name to "setup", then when you create a distribution consisting of a single file, you will receive the file setup.exe. In the “Custom Setup icon file” field, you can specify the name of the icon file for the future distribution. If nothing is specified here, it will be used standard icon. In the last field “Setup Password” you can specify the password that the user will have to specify during installation. If the “Use the password to encrypt the application files” checkbox is checked, then the files in the distribution will be encrypted using the specified password. For example, I will fill out all the fields in my own way.

The next step notifies you that the Inno Setup preprocessor has been detected and prompts you to use #defines to simplify your script. If you want to use the #define directive, leave the “Yes, use #define compiler directives” checkbox. If the checkbox is not checked, then, in the future, you can add #define directives to your script manually.

And finally the last step has appeared, where we simply click on the “Finish" button.

After this, the compiler immediately wants to compile our script. Let's agree and click the "Yes" button.

After this, the compiler will warn us that the script has not been saved and will offer to do so.

Let's agree (click "Yes") and save the script. After saving, the script was compiled and the finished distribution, in the example this is the file my-setup.exe, was created in the folder that I specified in the wizard at the “Compiler Settings” step. After compilation, you can see how it went in the “ Compiler Output” panel at the bottom of the compiler window, see the picture.

As you can see, everything is simple. Now let’s immediately test the finished distribution. Click on the menu item “Run -> Run” to start installing the program.

After creating the script template, you can start adding various advanced actions.

Debugging a distribution in Inno Setup

To debug your distribution, open the .iss script and click on the menu item “Run -> Run” to start the installation of the program. After this, you will be able to monitor internal processes during installation in the “Debug Output” window, you will be able to set breakpoints on the necessary lines, see the picture.

To check the value of a constant during debugging, click on the menu item “Run -> Evaluate Constant...” and in the dialog that appears, specify the name of the constant (see picture) and click “OK”.

After this, the following window will appear with the result returned by the constant.

To debug the uninstallation, click on the menu item “Run -> Target Uninstall”, and then “Run -> Run”. And to return back to the installation, click on the item “Run -> Target Setup".

Inno Setup script structure

Scripts in Inno Setup are divided into sections. The name of each section is enclosed in square brackets. Each section contains elements specific to that section. For convenience, you can create several sections with the same name. Such sections will be perceived as one. Here's an example:

[ Setup ] AppName = My Program [ Files ] Source : "MYPROG.EXE" ; DestDir: "(app)"

You can comment lines so that the compiler ignores them by prefixing them with a semicolon.

The script supports the C-like #include directive, which forces the compiler to pull in lines from the specified arbitrary text file, to the place where this directive is located. Here's the syntax:

#include "filename.txt"

With the #preproc directive you can specify which preprocessor to use: the built-in preprocessor, which supports only the #include directive, or the Inno Setup Preprocessor (ISPP), which supports a very large number of directives and functions. By default, scripts use the ISPP preprocessor if it is installed, and .isl files use the built-in preprocessor. Here's the syntax:

#preproc builtin #preproc ispp

Inno Setup script sections

I will provide here a complete list of all sections of Inno Setup with a brief description. Full description sections and a list of section elements can be found in the help in the “Setup Script Sections” section.

– this section contains global settings used during installation and uninstallation. Example:

[ Setup ] AppName =My Program AppVersion =1.5 DefaultDirName =( pf ) \My Program DefaultGroupName =My Program

– an optional section that defines installation options (Full/Compact/Custom), which will be displayed on the page for selecting components for installation. Example:

[Types] Name: "full"; Description : "Full installation" Name : "compact" ; Description : "Compact installation" Name : "custom" ; Description : "Custom installation" ; Flags: iscustom

– an optional section that defines the components that will be displayed on the page for selecting components for installation. Example:

[ Components ] Name : "main" ; Description : "Main Files" ; Types: full compact custom; Flags: fixed Name: "help"; Description : "Help Files" ; Types : full Name : "help\english" ; Description : "English" ; Types : full Name : "help\dutch" ; Description : "Dutch" ; Types: full

– optional section for creating additional tasks performed during installation. The user will see tasks in the form of switches and will be able to choose whether to perform one or another task or not. Example:

[Tasks] Name: desktopicon; Description : "Create a &desktop icon" ; GroupDescription : "Additional icons:" ; Components : main Name : desktopicon\common; Description : "For all users" ; GroupDescription : "Additional icons:" ; Components: main; Flags : exclusive Name : desktopicon\user; Description : "For the current user only" ; GroupDescription : "Additional icons:" ; Components: main; Flags : exclusive unchecked Name : quicklaunchicon; Description : "Create a &Quick Launch icon" ; GroupDescription : "Additional icons:" ; Components: main; Flags : unchecked Name : associate; Description : "&Associate files" ; GroupDescription : "Other tasks:" ; Flags: unchecked

– this optional section specifies which additional folders, in addition to the application folder, you need to create.

[ Dirs ] Name : "(app)\data" Name : "(app)\bin"

– an optional section that determines which files will be installed on the computer.

[Files] Source: "CTL3DV2.DLL"; DestDir: "(sys)" ; Flags : onlyifdoesntexist uninsneveruninstall Source : "MYPROG.EXE" ; DestDir : "(app)" Source : "MYPROG.CHM" ; DestDir : "(app)" Source : "README.TXT" ; DestDir: "(app)" ; Flags: isreadme

– an optional section that determines what shortcuts will be created in the Start menu, on the desktop, etc.

[ Icons ] Name : "(group)\My Program" ; Filename: "(app)\MYPROG.EXE" ; WorkingDir : "(app)" Name : "(group)\Uninstall My Program" ; Filename: "(uninstallexe)"

– an optional section that determines which entries will be added to the INI file.

[INI] Filename: "MyProg.ini"; Section : "InstallSettings" ; Flags : uninsdeletesection Filename : "MyProg.ini" ; Section : "InstallSettings" ; Key : "InstallPath" ; String: "(app)"

and - these optional sections determine which files or folders need to be removed, respectively, upon first installation or uninstallation. Example:

[UninstallDelete] Type: files; Name : "(win)\MYPROG.INI"

– the section defines the languages ​​that will be available during installation. When you run the installer, a language will be selected that matches the system language. Otherwise, the language located first in the section will be used by default. Example:

[Languages] Name: "en"; MessagesFile : "compiler:Default.isl" Name : "nl" ; MessagesFile : "compiler:Languages\Dutch.isl"

– section for replacing messages described in language .isl files. An example of replacing the standard text “&Next >” on a button to go to the next step for English only:

[ Messages ] en.ButtonNext =&Forward >

– section for defining the values ​​of the constant (cm:...), see the description of the constants above. Usage example:

[ CustomMessages] CreateDesktopIcon=Create a &desktop icon [ Tasks ] Name : desktopicon; Description : "(cm:CreateDesktopIcon)"

– section contains language settings, such as font. Example:

[ LangOptions ] LanguageName=English LanguageID=$0409 LanguageCodePage=0 DialogFontName= DialogFontSize=8 WelcomeFontName=Verdana WelcomeFontSize=12 TitleFontName=Arial TitleFontSize=29 CopyrightFontName=Arial CopyrightFontSize=8 RightToLeft=no

– This optional section determines which keys and values ​​need to be created, modified, or deleted in the registry. Examples of use:

[Registry] Root: HKCU; Subkey : "Software\My Company" ; Flags: uninsdeletekeyifempty Root: HKCU; Subkey: ; Flags: uninsdeletekey Root: HKLM; Subkey : "Software\My Company" ; Flags: uninsdeletekeyifempty Root: HKLM; Subkey : "Software\My Company\My Program" ; Flags: uninsdeletekey Root: HKLM; Subkey : "Software\My Company\My Program\Settings" ; ValueType: string; ValueName : "InstallPath" ; ValueData: "(app)"

– this optional section determines which programs need to be executed after successful installation, but before the final step appears in the installation wizard window. Examples:

[ Run ] Filename : "(app)\INIT.EXE" ; Parameters : "/x" Filename : "(app)\README.TXT" ; Description : "View the README file" ; Flags : postinstall shellexec skipifsilent Filename : "(app)\MYPROG.EXE" ; Description : "Launch application" ; Flags : postinstall nowait skipifsilent unchecked

– this optional section determines which programs need to be executed at the very beginning of the uninstallation.

– in this optional section you can place your Pascal script. The RemObjects Pascal Script engine is used to process the Pascal script. This engine is as free as Inno Setup. Official page engine RemObjects Pascal Script - . Examples of usage can be found in the files "Code*.iss" and "UninstallCode*.iss" in the "Examples" folder in the Inno Setup installation location.

Installation and uninstallation procedure

Very important point during installation, this is an understanding of the order in which the script is executed. The installer steps are listed below in the order in which they will be performed during installation:

      • Section execution.
      • Section elements are saved in the uninstallation log (which, at this stage, is stored in memory).
      • An application directory is created if necessary.
      • Sections are running.
      • The name of the uninstallation log file is reserved, if necessary.
      • The section is running (files are not being registered yet).
      • Section is running.
      • Section is running.
      • Section is running.
      • Files that should be logged are logged unless the system has to be rebooted. In cases where a reboot is required, registration occurs only after the system is restarted.
      • Add to list installed programs(Control Panel\Programs\Programs and Features), if necessary.
      • Section elements are saved in the uninstallation log.
      • The EXE file and the uninstaller log are saved to disk. After this point, the user is prohibited from canceling the installation, and any subsequent errors will not result in the installation being rolled back.
      • Section execution, except for section elements with the “postinstall” flag set, which will be executed after display last step installation wizard.
      • Update associations for files if the "ChangesAssociations" flag is set to "yes".
      • Notifies running applications that environment variables changed if the "ChangesEnvironment" flag is set to "yes".
      • As for the section elements, they will be executed in the order in which they are located within the section.

Uninstallation occurs in reverse order. But this does not apply to the and sections, which will be executed in the order in which they appear in the script (not in reverse order).

Preprocessor Inno Setup

I would like to write a few words about the Inno Setup preprocessor (ISPP). The main purpose of a preprocessor is to automate tasks during compilation and reduce the likelihood of typos in your scripts. For example, you can declare an ISPP (compile-time variable) variable containing the name of your application, and then use the value of that variable in multiple places in your script. If you later need to change the name of your application for some reason, you can do it in one place in your script. Without ISPP, you will have to find and fix all parts of the script where you use the application name, such as AppName, AppVerName, DefaultGroupName, etc.

Another example of using ISPP is to pull application version information from an EXE file and use it in the AppVerName statement in the section. Without ISPP, you will have to change the script every time the application version changes.

In addition, splitting the script into parts makes it possible to create a single script for different versions of your application (for example, trial and full-featured versions).

When using a preprocessor, it is important to remember that the preprocessor only works at compile time.

Calling the Inno Setup compiler from the command line

It would also be useful to know about the possibility of compiling the distribution from the command line. The compilation call looks like this:

compil32/cc

Here's an example:

compil32 /cc "c:\isetup\samples\my script.iss"

Calling compilation from the command line, in in this case, does not hide progress or error messages. The compiler returns 0 if compilation was successful, 1 if the command line parameters were passed incorrectly, or 2 if compilation failed.

An alternative compilation method is to use the console compiler ISCC.exe. Here is a diagram of how to use the compiler:

iscc [options]

Here's an example:

iscc "c:\isetup\samples\my script.iss"

Here are the main options:

/DO – disable distribution creation (changes all Output parameters in the script).
/EO – enable distribution creation (changes all Output parameters in the script).
/O – sets the path where the distribution will be created (changes all OutputDir parameters in the script).
/F – sets the distribution file name (changes all OutputBaseFilename parameters in the script).
/S – setting the SignTool parameter.
/Q[p] – for hidden compilation (only error messages are displayed, “p” displays progress).
/? – to display help.

Here's an example using options:

iscc /Qp /O"My Output" /F"MyProgram-1.0 " /Sbyparam=$p "c:\isetup\samples\my script.iss"

ISCC returns 0 if compilation was successful, 1 if the parameters were incorrect or an internal error occurred, or 2 if compilation failed.

In conclusion about Inno Setup

It will not be possible to talk about all the possibilities of Inno Setup in one article, it is very large volume information, so I described here only the main points. After reading, you can start using this amazing tool to create own distributions. In the future I will talk about alternative user interfaces. Now, write your comments on the article, and I will try to answer all your questions.