I have InstallScript code that executes a particular task. The task will either work or will not work. If the task works, I want to set a global variable to 1. If it does not work, I want to set a global variable to 0.
Somewhere down the line, I have another InstallScript code that executes. What I want is to check the global variable to see if it’s 1. If it is, fire off that code.
I know that I can modify the Install Exec Condition, but what I do not know how to do is to check for a global variable. How I can accomplish this?
In an InstallScript project, merely create and set a global variable, and code against it as you please.
If instead you are asking in the context of an MSI with custom actions that run InstallScript, you have to use MSI Properties as your global variables. Call MsiSetProperty to set it, and write your custom action’s condition against that property. Or call MsiGetProperty to retrieve it in your code and do the conditional execution there. Note that if the first action is in the UI sequence and the second is in the Execute sequence, you should add any properties you use to the
SecureCustomPropertiesproperty.To make this more concrete, your code might look like:
and your condition in the custom action might be simply: