Recently, I ran into a frustrating issue while creating an installer for my game using Inno Setup. At first, everything seemed fine the installer built without errors, and in many cases, it worked flawlessly. But occasionally, during installation, I’d get this dreaded message:
C:\game\Scared2\pad\graphics02.zip An error occurred while trying to copy a file: the source file is corrupted.
Even though the same files installed perfectly on some machines or other runs, sometimes a different file would throw the same error. One thing was consistent it always happened with large files, typically around or above 2 GB in size.
After digging into it, I figured out exactly what the problem was and how to fix it. Here’s everything I learned.
The Problem
This isn’t just a random bug. It’s a limitation of the Inno Setup system when dealing with large files, especially if you’re using aggressive compression settings like lzma/ultra64
. If the compressed archive size exceeds certain thresholds, the data can become unstable or even unreadable during the install process.
And that’s exactly what was happening in my case.
The Original Code
Here’s what my original Inno Setup script looked like:
[Setup]
InternalCompressLevel=ultra64
OutputDir=C:\SA
OutputBaseFilename=Instalace
VersionInfoVersion=2.65.1
VersionInfoCompany=Ascaron
Compression=lzma/ultra64
VersionInfoProductName=Sacred 2
VersionInfoProductVersion=2.65.1
DiskSpanning=true
AppName=Sacred 2
AppVerName=2.65.1
PrivilegesRequired=none
DefaultDirName={pf}\Sacred 2
DirExistsWarning=yes
DefaultGroupName=Sacred 2
AlwaysShowDirOnReadyPage=true
AlwaysShowGroupOnReadyPage=true
ShowTasksTreeLines=false
AppPublisher=Deep Silver
AppVersion=2.65.1
AppID={{EE72C138-0DFC-4C17-9859-EBC5A8AF7517}
UninstallDisplayName=Sacred 2
[Icons]
Name: {group}\Sacred 2; Filename: {app}\system\sacred2.exe; WorkingDir: {app}; IconFilename: {app}\system\sacred2.exe; IconIndex: 0
Name: {commondesktop}\Sacred 2; Filename: {app}\system\sacred2.exe; WorkingDir: {app}; IconFilename: {app}\system\sacred2.exe; IconIndex: 0
Name: {group}\{cm:UninstallProgram,Sacred 2}; Filename: {uninstallexe}
What Went Wrong
Large Files Cause Corruption
Inno Setup doesn’t handle very large compressed files (typically 2GB+) very well, especially with high compression modes like lzma/ultra64
. So when it tried to extract files like graphics02.zip
during installation, it failed.
Fix:
Mark large files as external
and disable compression for them.
[Files]
Source: "graphics02.zip"; DestDir: "{app}\pad"; Flags: external nocompression
No [Files]
Section Was Present
My original script didn’t even specify which files to install! That’s a problem.
Fix:
I added a proper [Files]
section to declare file sources and destinations.
[Files]
Source: "C:\game\Scared2\pad\graphics01.zip"; DestDir: "{app}\pad"
Source: "C:\game\Scared2\pad\graphics02.zip"; DestDir: "{app}\pad"; Flags: external nocompression
Broken AppID
Syntax
I accidentally left off the closing brace (}
) in the AppID
. Small mistake, but it broke the installer.
AppID={{EE72C138-0DFC-4C17-9859-EBC5A8AF7517}}
My Improve Script
After all the fixes and refinements, here’s the script I ended up using:
[Setup]
AppName=Sacred 2
AppVerName=Sacred 2 v2.65.1
AppVersion=2.65.1
AppID={{EE72C138-0DFC-4C17-9859-EBC5A8AF7517}}
DefaultDirName={pf}\Sacred 2
DefaultGroupName=Sacred 2
OutputDir=C:\SA
OutputBaseFilename=Instalace
Compression=lzma2/ultra64
InternalCompressLevel=ultra64
DiskSpanning=true
DirExistsWarning=yes
PrivilegesRequired=none
AlwaysShowDirOnReadyPage=true
AlwaysShowGroupOnReadyPage=true
ShowTasksTreeLines=false
VersionInfoVersion=2.65.1
VersionInfoCompany=Ascaron
VersionInfoProductName=Sacred 2
VersionInfoProductVersion=2.65.1
AppPublisher=Deep Silver
UninstallDisplayName=Sacred 2
[Files]
Source: "C:\game\Scared2\pad\graphics01.zip"; DestDir: "{app}\pad"
Source: "C:\game\Scared2\pad\graphics02.zip"; DestDir: "{app}\pad"; Flags: external nocompression
; Add more files if needed
[Icons]
Name: {group}\Sacred 2; Filename: {app}\system\sacred2.exe; WorkingDir: {app}
Name: {commondesktop}\Sacred 2; Filename: {app}\system\sacred2.exe; WorkingDir: {app}
Name: {group}\{cm:UninstallProgram,Sacred 2}; Filename: {uninstallexe}
Extra Functional Feature I Added
To make the installer feel more complete, I added some practical functionality:
Proper Uninstaller Cleanup
[UninstallDelete]
Type: filesandordirs; Name: "{app}"
Custom Welcome Message
[Messages]
WelcomeLabel1=Welcome to the Sacred 2 Installer
Disk Space Check Before Installation
[Code]
function InitializeSetup(): Boolean;
begin
if GetSpaceOnDisk('C:\', False) < 500000 then
begin
MsgBox('Not enough disk space on C drive!', mbError, MB_OK);
Result := False;
end
else
Result := True;
end;
Final Thought
What seemed like random errors were actually signs of a known limitation: Inno Setup isn’t built to handle huge compressed files well. Once I understood that and adjusted my script by disabling compression on large files, defining [Files]
properly, and correcting syntax it worked like a charm.
If you’re using Inno Setup for game installers (or anything with large assets), I highly recommend:
- Using
external
+nocompression
for files over 2 GB - Always defining your
[Files]
section clearly - Testing on multiple machines to catch these edge cases early.