Archive: Making an Installer from an existing Installer and a Configuration file


Making an Installer from an existing Installer and a Configuration file
Hi,

I have an Installer A.exe, created by NSIS, which is the same for all customers. Furthermore a have a dynamically created config file B.ini which differs for each customer. Given A.exe and the customer-specific config file B.ini, I would like to bundle these two files into an NSIS installer C.exe which installs A.exe and copies B.ini to the install dir.

What is the simples way to do so?

I'm new to NSIS and would appreciate any help or source code. Thank you!


I'm assuming you're asking how to automate the process of creating all the C.exes for all your customers.

The easiest way I can think of is putting all the config.ini files in subfolders (or renaming them (customerID).ini or something), then enumerate all the ini paths/filenames in a vbs/bat/NSISexe and executing makensisw for each filename with the filename supplied as a commandline parameter. You can use makensisw's /D parameter to specificy a !define during compilation, so that in the nsi script you'd do something like:
File "/oname=$INSTDIR\config.ini" "${TheFilenameDefine}"

Of course you'll also need to change the filename of each generated C.exe. Simply do: name ${TheFilenameDefine}.exe


Thank you very much for your reply. This already helps a lot. However, I'm wondering if there is a possibility to write the config file B.ini without creating a C.exe for every customer.

In other words: Is there a possibility to just append the config file B.ini of a specific customer (that is the raw bytes) to the installer A.exe without invoking makensis and specify a command in the script for A.exe which looks for this config data and if it exists writes it to the file B.ini during installation?


Yes, there is. NSIS installers only do a CRC check on their own data. If you append bytes to the exe, it will not interfere with the installer. If you want to use an NSIS exe to do this, you can use FileWriteByte. You'll have to make sure that the correct bytes are read during installation (FileReadByte). Perhaps using a fixed filelength for each ini would be the simplest way.

Note however that if the ini contents are already known during compilation of A.exe, you can simply use the ini instructions to create the config.ini file at runtime: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.13


Thanks for your reply. I was able to solve the problem by writing a function based on ReadCustomerData http://nsis.sourceforge.net/ReadCustomerData. However I'm running into trouble if the appended data contains linebreaks, so I had to escape \r and \n and remove the escaping when writing the appended data back to aconfig file.