I have a custom action (UI sequence) that writes some property, say PROP1:
Code: Select all
AI_SetMsiProperty PROP1 "Some value"
Then in some UI dialog in init actions, I have another custom action (no sequence) which reads same property:
Code: Select all
$PropName = "PROP1"
$PropValue = AI_GetMsiProperty $PropName
Note that property name is set inside variable (in fact, its name is built in runtime, but final property name is exactly the same) not as literal. And in this case, $PropValue receives empty value, rather than the one set by previous custom action. What is the weirdest thing here is if I put:
which is a comment in PowerShell so has to be ignored, but then property value is retrieved correctly. I've attached a minimal repro project. Look at custom actions: Write is setting some value to PROP1 in UI sequence. Then Read is configured in Init Actions in Welcome dialog. I set property name in variable then read. And in the end I added pointless (from PowerShell perspective) line which reads property as literal. This makes the code above to work. When you remove this line, PROP1 won't be retrieved by a script above.
I suspect that you do some static script parsing before actually execute it, but it doesn't make my life easier.
Just to make a point: I have a custom action which contains some common logic to process properties and I determine actual property name to read in runtime, say:
Code: Select all
$context = AI_GetMsiProperty
$PropName = switch ($context) {
# do case statements to figure out which property to read
}
$PropValue = AI_GetMsiProperty $PropName
# do whatever logic needed to handle requested property value
which doesn't allow me to use constants or literals in the script, without duplicating scripts which is a no go for me.
Any way to overcome this issue? Maybe, there is a better way to handle dynamic (determined in runtime) MSI properties?