cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
avanderwoude
Level 3

Using Strings/Properties in the command-line args of a Custom Action

I need to install some third-party software (call it Foomatic) by running its installer.

So first I created a Feature named Foomatic. It has no Components, because the work will be done by a Custom Action. (By the way, if anyone can point out how to do this work in a Component instead I'm all ears!)

On the Support Files pane, I added all the Foomatic files to the Language Independent section. These files include Install.exe, some dlls, etc. As far as I can tell, Install.exe is a proprietary piece of software, not an MSI installer or anything like that.

I created a String named FOOMATIC_LICENSE_KEY that has the necessary value.

I created a "New EXE" Custom Action named InstallFoomatic, which I configured as follows:


  • Working directory:
  • Filename & Command line: "[SUPPORTDIR]\Install.exe" -license "{FOOMATIC_LICENSE_KEY}"
  • Install Exec Sequence: After InstallFiles
  • Install Exec Condition: &Foomatic = 3
  • All other settings: default values


When I try to run this the install fails with Error 1721. Logging with *xv reveals that the command line is not expanding the FOOMATIC_LICENSE_KEY variable, although it is resolving SUPPORTDIR correctly. I also tried creating a Property for the license key value, because that hopefully will let me hide the value in the log file, but that wasn't expanded either.

Can anyone explain what I am doing wrong?
Labels (1)
0 Kudos
(9) Replies
pv7721
Level 20

The only difference I could see is that you surrounded the SUPPORTDIR with brackets, where you surrounded the other variable with accolades.
0 Kudos
avanderwoude
Level 3

As I understand it, the square brackets are used for directories and the braces are used for strings and properties. At least, that's what the documentation shows...
0 Kudos
avanderwoude
Level 3

I think I may understand what is going on. Since I'm dealing with deferred Custom Actions, there is a limited subset of items available when they execute (see the help topic "Accessing or Setting Windows Installer Properties Through Deferred, Commit, and Rollback Custom Actions"). It seems likely that I'm running afoul of this. The easiest way to deal with it is to hard-code the license key on the command line, and not attempt to use a String or a Property. I'd have to start writing InstallScript programs to make stose available, and I just don't have the time for that.

If I have overlooked something obvious, please let me know.
0 Kudos
RobertDickau
Flexera Alumni

Actually, if you pass a property (using [PropName]) as an argument to an executable, the deferred-action considerations don't apply. It's only in code or a script (InstallScript, C, VBScript, etc.) that you need that CustomActionData handling.

The {String_ID} form applies only in the InstallShield environment. To pass a value into the command line, use [PropName] as you did earlier in the command.
0 Kudos
avanderwoude
Level 3

Yippee, using square brackets works!

Only one problem left on this topic: even though I created a Property for the license key, and added it to MsiHiddenProperties, the actual value of the license key shows up in the expanded command line when logging with *xv. Ironically, the section of the log file that displays all the the Properties stars out the license key. Is this just an oversight in the product?
0 Kudos
RobertDickau
Flexera Alumni

For one explanation, please see the MSI help topic "Preventing Confidential Information from Being Written into the Log File".
0 Kudos
avanderwoude
Level 3

Yes, reading that topic is how I learned about MsiHiddenProperties. This works when the Property is logged, but not when the Property is expanded in a command line. For example, consider the Custom Action that runs the Foomatic installer with the following command:


"[SUPPORTDIR]\Install.exe" -license "[FoomaticLicenseKey]"


The relevant parts of the log file (logged at level *xv) are:

MSI (s) (C4:30) [12:41:39:076]: Executing op: CustomActionSchedule(Action=InstallFoomatic,ActionType=1058,,Target="C:\temp\{68BD0CE4-5EBE-4356-B0E1-5AFF0E43B853}\Install.exe" -license "topsecret",)
...
Property(S): FoomaticLicenseKey = **********
Property(S): MsiHiddenProperties = FoomaticLicenseKey


As you can see, it's working correctly when the Properties are being listed, but not in the expanded command line. I strongly suspect this is a bug where placeholders are expanded in order to create the command line, and the result is simply logged. You'd have to keep track of both the real command line and a version suitable for logging.
0 Kudos
RobertDickau
Flexera Alumni

It seems not to be exposed in the custom action settings in the Installation Designer, but does the logging behavior change if you use the Direct Editor view to view the CustomAction table, and add 8192 (the "custom action hidden target" bit) to the value in the Type column? (Mentioned at the end of the list on "Preventing Confidential Information from Being Written into the Log File".)
0 Kudos
avanderwoude
Level 3

You're absolutely right, adding 8192 to the Type value makes the entire expanded command line starred-out in the log file. It's a pity that the entire line is hidden rather than just the license key value, but it sure beats the alternative. Thanks very much for your help.
0 Kudos