Overview
Inno Setup is a powerful tool for creating installation packages. This guide will walk you through using Inno Setup to compile and package your application, along with addressing common issues encountered during the installation process.
How to Use Inno Setup Compiler
Download and Install Inno Setup:
- Obtain the latest version of Inno Setup from the official website.
- Follow the installation wizard to install the Inno Setup Compiler on your machine.
Creating a Script:
- Open Inno Script Studio (included with Inno Setup) or your preferred text editor.
- Write or edit your installation script (
.iss
file), defining setup options, files, registry entries, and more.
Compiling the Script:
- Open the
.iss
file with the Inno Setup Compiler.
- Click “Compile” to build the installer. This process creates a single executable installer based on your script.
Testing the Installer:
- Run the generated installer to ensure it works correctly.
- Test all installation paths, including full install, upgrade, and uninstall scenarios.
Deploying the Installer:
- Distribute the installer executable to end-users or through your preferred distribution channels.
Key Sections and Tags in Inno Setup
[Setup]
- Purpose: Defines the basic configuration of the installer, including application name, version, installation directory, and supported architectures.
- Installation Stage: Throughout the entire installation process.
[Files]
- Purpose: Specifies the files to be installed and their destination directories.
- Installation Stage: Install phase, typically executed early to mid-installation.
[Dirs]
- Purpose: Creates directories required for the application.
- Installation Stage: Install phase, generally executed before
[Files]
.
[Icons]
- Purpose: Creates shortcuts, such as desktop icons or Start Menu entries.
- Installation Stage: PostInstall phase, after file installation is complete.
[Run]
- Purpose: Runs programs or commands after the main installation is complete.
- Installation Stage: PostInstall phase, used for setup configurations, environment variable updates, or launching the application.
[UninstallDelete]
- Purpose: Specifies files or directories to be deleted during uninstallation.
- Uninstallation Stage: Uninstall phase.
[UninstallRun]
- Purpose: Runs commands or programs after uninstallation.
- Uninstallation Stage: PostUninstall phase.
[Registry]
- Purpose: Creates or modifies registry keys and values during installation.
- Installation Stage: Install phase.
[Code]
- Purpose: Contains Pascal scripts for custom actions and complex logic during installation.
- Installation Stage: Can be involved in Install, PostInstall, Uninstall, and PostUninstall phases.
Installation Flow and Stages
Initialization (Initialization):
- Initial checks and setup, such as OS version verification and admin privilege checks.
PreInstall (Pre-installation):
- Preparation steps, including setting up the environment.
Install (Installation):
- The core installation phase, involving file copying, directory creation, and registry configuration.
PostInstall (Post-installation):
- Finalization steps like creating shortcuts and running post-install commands.
Uninstall (Uninstallation):
- Removing installed files and cleaning up registry entries.
PostUninstall (Post-uninstallation):
- Final cleanup tasks and command executions after uninstallation.
Common Issues and Solutions
1. Progress Bar Shows 100% but Installation is Not Complete
- Issue: The progress bar reaches 100%, but additional time is needed to complete the installation.
- Solution: Ensure all lengthy operations are accounted for in progress updates. Use custom progress messages to inform the user of ongoing processes.
2. Disk Spanning Must Be Enabled Error
- Issue: Error occurs indicating that disk spanning must be enabled due to the installer size.
- Solution: Adjust your installation package to reduce size or enable disk spanning in the
[Setup]
section.
3. System Environment Variables Not Being Set Properly
- Issue: Environment variables are not correctly updated or set.
- Solution: Use
[Registry]
or [Code]
sections to ensure environment variables are set correctly, and verify permissions.
4. Uninstallation Leaves Files Behind
- Issue: Certain files or directories remain after uninstallation.
- Solution: Verify
[UninstallDelete]
and [UninstallRun]
entries to ensure all files and directories are correctly specified for removal.
5. Custom Code Execution During Uninstallation
- Issue: Need to perform custom actions during uninstallation.
- Solution: Implement
procedure UninstallStep
or similar functions in [Code]
to execute custom logic.
By understanding and utilizing these sections and handling the installation stages correctly, you can ensure a smooth and efficient installation process for your software.