Creating a Windows Installer with Inno Setup
If you’re making a Windows game, one of the tasks you must perform is to create an installer for the game. Coming from Mac OS X, where installers are rarely used, I was a little worried about making an installer for the Windows version of Letter Miner. But after doing some Internet research, I came across Inno Setup, a free tool that greatly simplifies making an installer for Windows. In this article I’ll explain how to use Inno Setup to create a basic Windows installer.
Using the Script Wizard #
The easiest way to start with Inno Setup is to use its script wizard. Launch Inno Setup and choose File > New to open the script wizard. The wizard creates a basic shell of an install script. Using the wizard allows you to specify the following without having to write any code:
- The name of your application
- Your company name
- Your company URL
- The version number
- Where to install the application
- The Start menu folder name
- Whether or not to create a desktop icon
- A license file to use
When you finish with the script wizard, you have a basic installer that installs your application. Games usually have additional files to copy, such as graphics, sound, and data files. You must add them manually to your script to have them installed when the player runs the installer.
Adding Files to Install #
If you look through the script the script wizard created, you will find a Files section in the script that looks similar to the following:
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
To add your game’s files to the installer, you must add them to the Files section, one listing for each file in the game. The following example copies SDL’s DLL file to the same directory as the application when installing the application:
Source: "SDL.dll"; DestDir: "{app}"
This example assumes the file SDL.dll is in the same directory as the script you are writing. You may find it safer to pass the full path to the file on your computer.
Source: "C:\Path\To\SDL.dll"; DestDir: "{app}"
Running Other Programs During the Install #
If you use Visual C++ to write your game, your installer may need to run the Visual C++ Redistributable Package so that someone who does not have Visual C++ on their computer can play your game. Running another program in the installer is a two-step process. First, you must add the program to the Files section. The following example copies the Visual C++ Redistributable Package:
Source: "vcredist_x86.exe"; DestDir: "{app}"
Second, you must add the program to the Run section of the installer script (look for [Run] in the script). The following example runs the Visual C++ Redistributable Package:
Filename: "{app}\vcredist_x86.exe"
Compiling the Script #
When you finish writing your script, choose Build > Compile to compile it. The default name for the installer Inno Setup creates is setup.exe, but the actual name depends on what you entered in the script wizard. Choosing Run > Run allows you to run and test the installer you created.
Additional Information #
This article provides a basic introduction to using Inno Setup. Additional information is available from Inno Setup’s Help menu, including example scripts.