I'm afraid that this is not supported directly by Windows Installer.
However, you can set properties using the command line and use them as parameters for your custom action. For example if you run a MSI package with the command:
My installation has many command line parameters and I needed to do a lot of processing on those parameters both before and after installation of the files.
My pre-processing included verification of the command line parms such that if it failed, then the actual install would stop before a single file was extracted. The post install included editing an application config file to include some of the command line parms. While you cannot get the full command line as a single property, you can pass individual properties.
In my case, the magic happens in the Advanced Installer >> Custom Actions >> Install and Commit phases. I created a simple DLL using MS Visual Studio that exposed a simple validation routine and an editing routine for the install and commit phases respectively. Then you pass the properties (case matters) on the command line like DEBUG="true" or PORT=1024 and also put them into the Advanced Installer's >> Custom Action >> action data field in brackets like debug=[DEBUG] port=[PORT].
In the DLL (you can also java script or visual basic script) you get the installer properties using:
ok = GetMsiProperty("CustomActionData", sMyCustomActionValue);
My DLL's are quite extensive doing a lot of verification, pulling certificates across the network and editing files which compliment advanced installer very nicely. The trick (most time lost) was figuring out how to get the command line parms into advanced installer and then into my code. It turned out to be quite easy. It was also very easy to waste a lot of time. Hints:
1. Property case (scope) matters
2. Properties are specified in brackets like [DEBUG] will produce the value "true".
3. Some properties require a special vertical bar following them (I don’t remember why).
4. There was no need to define the properties in the Advanced Installer >> Install Parameters >> Properties panel.
5. You CAN access properties during install using Custom Actions >> Install >> Synchronous >> Deferred with no impersonation for Vista. However, the actual files are NOT available during this phase because the install hasn’t started yet.
6. You can NOT access properties during the commit phase, but you CAN access the files because they have already been extracted.
7. To keep properties values between install and commit phase, your external program must persiste them somewhere (like the registry or some temp file, but not in memory since the DLL access from each phase is completely independent.
I am not aware of an API to get the log file name, but I would not doubt you get it from the handle provided by the custom action entry point.
Here's a scaled down example of a DLL entry point (using visual c++). The entry point is exposed to Advanced Installer >> Customer Action >> Install (phase) >> Function Name. When the install phase executes, it calls my DLL with a handle from MSI which can then be used to write records to the log file.
Again, I wouldn’t doubt there is a way to get the actual filename.
Alternatively, you can pass a property LOG="MyLogFile.log" on the command line (as suggested earlier) and write to that file using typical file functions. This works (I did this too for a while) but then your log messages are not integrated with the MSI log messages which provides limited value.
3. Some properties require a special vertical bar following them (I don’t remember why).
AI documentation refers to the vertical bar ("|") as the pipe character. It appears to have different uses in different contexts. My context is in Extract Location.
In the case of the Extract Location text field, the pipe character is part of the property referencing syntax. This text field is PseudoFormatted which means the property references are replaced with the value of the respective properties at build time.
Thanks Mihai, may I suggest adding the phrase "pipe character" to the PseudoFormatted documentation page. Help's Search won't allow you to search for the "|" character so I wasn't able to find the page you referenced on my own. BTW, I call this character a vertical bar.
FOLLOW US
Get the latest news in Application Packaging