Structure of an Inno Setup script


(Example: D EPLOY F OX D EMO A PP S CRIPT WIZARD SCRIPT.ISS)

As mentioned previously, an Inno Setup script is an ASCII text file with an ISS file name extension. Entries in an Inno Setup script file are organized into sections much like an INI file: section headers are enclosed in square brackets and each section header is followed by one or more section entries, one entry per line. This simple structure makes Inno Setup scripts very easy to read and edit using any text editor, although using Inno Setup itself or a third-party tool such as ISTool provides several advantages such as syntax coloring and one-click compilation.

The script we generated with the script wizard in the previous section of this appendix is shown in Listing 1 . Even without knowing anything about Inno Setup ‚ s syntax, you should find the script fairly easy to understand. Any line in a script can be turned into a comment by prefixing it with a semi- colon . The comments in Listing 1 were inserted by the script wizard.

Listing 1. This is the script generated by the Inno Setup script wizard.
  ; Script generated by the Inno Setup Script Wizard.   ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!   [Setup]   AppName=DeployFox Demo App  AppVerName=DeployFox Demo App 1.0  AppPublisher=Information Technology Associates  AppPublisherURL=http://www.ita-software.com  AppSupportURL=http://www.ita-software.com  AppUpdatesURL=http://www.ita-software.com  DefaultDirName={pf}\DeployFox\AppendixD\Demo App  DefaultGroupName=DeployFox\AppendixD  LicenseFile=C:\DeployFox\AppendixD\License.rtf  InfoBeforeFile=C:\DeployFox\AppendixD\InfoBefore.rtf  InfoAfterFile=C:\DeployFox\AppendixD\InfoAfter.rtf   [Tasks]   Name: desktopicon; Description: Create a &desktop icon; GroupDescription:  Additional icons:   [Files]   Source: C:\DeployFox\DemoApp\demoapp.exe; DestDir: {app}; Flags: ignoreversion  Source: C:\DeployFox\DemoApp\DEMOAPP.CHM; DestDir: {app}; Flags: ignoreversion  Source: C:\DeployFox\DemoApp\readme.txt; DestDir: {app}; Flags: ignoreversion  Source: C:\DeployFox\DemoApp\Data\customers.DBF; DestDir: {app}\Data; Flags:  ignoreversion  Source: C:\DeployFox\DemoApp\Data\customers.CDX; DestDir: {app}\Data; Flags:  ignoreversion  ; NOTE: Don't use "Flags: ignoreversion" on any shared system files   [Icons]   Name: {group}\DeployFox Demo App; Filename: {app}\demoapp.exe  Name: {group}\Uninstall DeployFox Demo App; Filename: {uninstallexe}  Name: {userdesktop}\DeployFox Demo App; Filename: {app}\demoapp.exe; Tasks:  desktopicon   [Run]   Filename: {app}\demoapp.exe; Description: Launch DeployFox Demo App; Flags:  nowait postinstall skipifsilent  
 
On The Web ‚  

The script in Listing 1 is included in the appendix ‚ s source code as DEPLOYFOX DEMO APP SCRIPT WIZARD SCRIPT.ISS.

Note ‚  

Some entries in this script are more than 80 characters long and take two lines to display in Listing 1. In the actual script file, each entry is a single line. Refer to Figure 8 or open the script file in Inno Setup to see where the real line breaks are.

Inno Setup scripts employ constants to represent elements whose values are not determined until installation time. Constants are enclosed in braces. Looking at Listing 1 you can see several constants such as {pf}, {app} , and {group}. At installation time {pf} evaluates to the user ‚ s Program Files folder, {app} evaluates to the folder the user selects for installation of the application, and {group} evaluates to the user ‚ s Start Menu folder.

The names of the Inno Setup constants are fairly descriptive, so when you ‚ re reading a script it ‚ s pretty easy to figure out what a constant means even if you haven ‚ t seen it before. For example, in addition to the constants mentioned above, {win} represents the directory where Windows is installed on the user ‚ s machine, and {sys} represents the Windows System directory. The Inno Setup Help file has a complete list of these constants.

Inno Setup uses flags to supply additional information about the entries in some sections of a script. Like constants, the names of these flags are also descriptive of what they do. For example, the ignoreversion (ignore version) flag does what you would expect it to do: it tells Inno Setup to ignore the version of an existing file in the target directory and to overwrite it with the file from the setup package.

Setup section

Every Inno Setup script starts with a Setup section. This section contains the global settings and identifiers for the installation. The syntax for entries in the Setup section is directive = value , where directive is an Inno Setup keyword and value is the value assigned to that directive.

There are nearly one hundred possible Setup section directives. The actual number of directives in a particular script of course depends on the installation requirements for the application. Three of the directives are required in every script, though. These are:

  • AppName , which is the title of the application being installed

  • AppVerName , which is generally the same as the AppName, but it also includes the version number

  • DefaultDirName , which supplies the default installation directory for the application

The Inno Setup Help file contains a complete listing of Setup section directives. We do not cover them all in this appendix, but we introduce several of them later when we complete this script prior to compiling it. Looking at Listing 1, you will note that the script wizard generated several other directives in addition to the three required ones. Again, because of the simple text nature of an Inno Setup script, it ‚ s pretty easy to read the script and figure out the purpose of the other directives. It ‚ s also easy to see the correlation between the entries in the Setup section and the entries we made in the script wizard.

Tasks section

The Tasks section defines the user-selectable tasks Inno Setup will perform during installation. Unlike the Setup section, the syntax for entries in the Tasks section, as well as for all other sections of an Inno Setup script, is a string of parameter and value pairs separated by semi- colons. Each parameter and value pair consists of the name of the parameter, a colon, and the value assigned to that parameter.

Just by looking at it, you can probably figure out the entry in the Tasks section in Listing 1 tells Inno Setup to create a desktop icon for the application. At installation time, the user will see a check box for this task and they can select or clear this task. By default, the check box displays as selected, but this can be changed by adding Flags: unchecked to the entry.

Files section

The Files section, as you would expect, is where you list the files you want to copy to the target computer during installation. Like the Tasks section, the syntax for each entry in the Files section is a string of parameter and value pairs separated by semi-colons. You must specify the source name and destination directory for each file you want to install. The destination file name defaults to the same as the source file name, although a different destination file name can be specified if necessary.

A set of one or more flags can be associated with each file in the Files section. Flags provide additional options that determine how Inno Setup handles the file during installation. Because each individual file has its own flags, you can exercise granular control over how each file is handled. Flags are commonly used to tell Inno Setup what to do if a file of the same name already exists on the target computer. Flags can also be used to identify shared system component files, to register ActiveX controls, and to mark files as permanent (i.e., never uninstall).

Looking at Listing 1, you can see the files to be copied to the target computer and where they are to go. Note that the script wizard added the ignoreversion flag to the entry for all of these files. As noted previously, the ignoreversion flag tells the Inno Setup installer to copy the files to the destination folder regardless of whether another version ‚ either older or newer ‚ of the same file already exists.

Remember ‚  

The ignoreversion flag is desirable for versioned files such as the application ‚ s main EXE, which should be overwritten when an update is installed. However, you typically do not want to overwrite the user ‚ s data files when installing an update. To avoid overwriting the user ‚ s data files when installing an update you can use the onlyifdoesntexist flag that tells Inno Setup to copy the file only if it doesn ‚ t already exist in the destination directory. As a further protection against the inadvertent loss of users ‚ data files you may also want to add the uninsneveruninstall flag, which tells the uninstaller not to remove these files when the application is uninstalled .

Alternatives to ignoreversion include confirmoverwrite , onlyifdestfileexists , and onlyifdoesntexist , whose meanings are self-evident from their names. Another useful flag is overwritereadonly , which tell Inno Setup to overwrite a read-only file of the same name without prompting. For example, if you make your main executable read-only, use the overwritereadonly flag to avoid a ‚“confirm overwrite read-only file ‚½ dialog that would otherwise appear when copying an updated version of the file during installation.

The Inno Setup Help file contains a complete list of the flags you can use in the Files section along with their meanings.

Icons section

The Icons section defines the shortcuts to create for the application. This includes both desktop icons and Start Menu entries. Although this section is optional, most installations will want to create at least one shortcut for the user to launch the application.

Listing 1 shows three entries in the Icons section of our setup script. The first entry creates a Start Menu entry for the application and points it to DEMOAPP.EXE in the directory the program is installed. In this entry, the constant {group} is the path to the user ‚ s Start Menu. The second entry in the Icons section in Listing 1 creates an uninstall icon in the same location.

The third entry is for creating the desktop icon. Note that this entry is tied to the ‚“desktopicon ‚½ task defined earlier in the Tasks section of the script. This is how Inno Setup implements the user ‚ s choice about creating a desktop icon. If the user selects the check box for the desktop icon at installation time, the ‚“desktopicon ‚½ task is performed and the icon is created. If the check box is clear, the task is not performed and the desktop icon is not created.

Run section

The Run section is also optional. This section is used to define one or more programs to run after the installation is complete. Programs executed from the Run section of the script will run before Inno Setup displays the final step of the setup wizard.

The Run section is commonly used to display the readme file and, optionally , to launch the application itself when installation is completed. Other uses for the Run section include firing off a post-installation process you want to run before the application itself is launched. For example, you can place an entry in the Run section to update the structure of the user ‚ s data files if necessary.

In Listing 1 you can see one entry in the Run section. This entry gives the user the option of running the application when installation is complete. Like the entries in the Files section, entries in the Run section use flags to provide additional information. The flags used in the example in Listing 1 have the following meaning:

  • nowait tells Inno Setup not to wait for completion of the program in this Run entry before proceeding with the next Run entry;

  • postinstall tells Inno Setup to create a check box for this entry on the setup wizard ‚ s Setup Completed page, thus giving the user the choice to run or not to run this entry;

  • skipifsilent tells Inno Setup to skip this entry if running in ‚“silent setup ‚½ mode.

Other flags in the Run section include shellexec , which can be used to open any registered file type ‚ for example PDF, TXT, or DOC ‚ with its associated application, and skipifdoesntexist , which bypasses the step without displaying an error message if the filename specified doesn ‚ t exist. Note that when using the shellexec flag, the file type must be registered on the user ‚ s machine (not on your machine) or an error message results when Inno Setup attempts to open that file at installation time. If you can ‚ t be certain the associated application is installed on the user ‚ s machine, you may not want to use shellexec . As with the other sections, complete information on shellexec and everything else about the Run section is available in the Inno Setup Help file.

Other sections

Inno Setup provides for several other sections in a setup script. Among them are a Types section for specifying types of installations (for example full, minimum, or custom), a Components section for defining the various components the user can select when performing a custom installation, a Registry section for creating registry entries, an INI section for defining INI file entries, and UninstallRun and UninstallDelete sections to use for providing additional options during uninstallation.




Deploying Visual FoxPro Solutions
Deploying Visual FoxPro Solutions
ISBN: 1930919328
EAN: 2147483647
Year: 2004
Pages: 232

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net