1

How can I add a config file with a special uniquely generated token to a msi file? The idea is that the user registers a client computer and the installer comes with the unique values in a config file. I´ve read about the msidb.exe but I would like to know if there is a better, cleaner and easier solution. Any ideas?

1 Answers1

0

Adding Custom Files: You can add a custom file to an MSI, there are a few ways to do so, but it is quite involved and clunky. Commercial tools such as Wise (no longer available) allowed easy ways to add such files. You can also manually edit the Media and Cab tables. I wrote this answer long ago with some details: Adding an external CAB to an MSI with an internal one.

Parameterized Setups: Is that token some sort of encryption or license key? I assume you want to supply some custom parameters to the setup? What does that entail? License? Server names? User names? URLs? Or is this a generated, binary file for your users that can not be easily generated by the setup? If these are just configuration settings, the better way might be to use a transform to set installation parameters or you can supply parameters to an MSI when it is installed via the msiexec.exe command line. The use of transforms and the use of command line parameters for msiexec.exe are both described here: How to make better use of MSI files. Essentially you set properties that will be inserted into configuration files during installation. Essentially transforms are little database fragments with settings applied at installation time to modify an original installation with user-specific settings. As such it is essentially what you need. Maybe. Transforms can in principle also be auto-generated - by applying some elbow grease and patience.

MSI Configuration: Once your parameters have been passed to the installation process, you can write them into INI files easily using built-in MSI constructs. There are also extensions in all major tools that allow you to write XML. And there are several other extensions to set firewall options for example, and God knows what. What kind of config file are we talking about? You can also use custom actions to basically do whatever you want in terms of updating files and other things on the system - with the cost of all the bug potential that comes from rolling your own solutions.

Application: Often it is better to do application configuration using the application itself after installation. This can drastically simplify the process of debugging and supporting the application rather than depending on a "one-shot-affair" setup without interactive error messages for users to report to support.

Summary: So in essence what I am saying is that you can either inject the file as you suggest, you can supply parameters to the setup via transforms or command line to write or generate the files on disk, or you could have your application generate the binary file from the settings you have written to INI or XML files during application launch. You can also obtain the custom values you want to write to the config files via the setup GUI instead of via PUBLIC properties on the command line.


Some Links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164