Modify the config file in the compiled Inno Setup installer (custom config file for each downloadable executable)
I am working on a project that needs a unique way of working that requires the Windows exe installer (packaged using Inno Setup) to be updated with a different config file containing a unique ID for each download.
The project itself is a web framework for which I am using PHP on Apache and Linux.
The installer contains a Windows binary executable and a config.ini
. I just need to edit the file config.ini
every time the file is ready to upload. Updates are just an incremental counter.
I find no direction for the approach as I am considering editing a packaged Inno Setup file created on Windows for editing on a Linux server.
Can anyone point me to some ideas to achieve this please.
Thanks,
Sk
source to share
Just save the config file in the installer uncompressed for easy modification. Use nocompression
flag . You must also use dontverifychecksum
flag , otherwise the installer will treat the modified file as corrupted during installation.
[Files] Source: "config.ini"; DestDir: "{app}"; Flags: nocompression dontverifychecksum
You also cannot change the length of the file. Therefore, you need to reserve enough space in the file for large numbers, for example:
[Section] Counter=?????
To change the installer using PHP, you can do the following:
$counter = $_GET["counter"];
$filename = "mysetup.exe";
$contents = file_get_contents($filename);
$mask = "?????";
$prefix = "Counter=";
$replace = $prefix . $mask;
$p = strpos($contents, $replace);
if ($p !== false)
{
$s = $prefix . str_pad($counter, strlen($mask), "0", STR_PAD_LEFT);
$contents = substr($contents, 0, $p) . $s . substr($contents, $p + strlen($replace));
file_put_contents($filename, $contents); // or feed directly to the output stream
}
If you sign the installer (you must), you must sign it after you change it.
Or see Paste User Specific Data into Signed Wildcard Installer at Boot
source to share