问题
I have InstallShield 2013 Basic MSI project I want to have a CA that will run after the files are being installed but before creating the shortcuts, how can I do that ? I tried to create CA that will run after InstallFile but when running the setup I see that when it get to InstallInitialize it skip all CA excepts the one I added and it run it and after that go back to InstallInitialize and run all custom action it has skipped.
回答1:
What you're seeing here in the log is the effect of Deferred Execution actions in the InstallExecuteSequence. Each deferred action between InstallExecute
and InstallFinalize
is written into a script as it is encountered. Then, as part of InstallFinalize
, all actions in the script are executed. (Unless there are failures, in which case rollback actions get involved, and the remaining deferred actions are skipped.)
Most built-in actions either have deferred components, or are entirely deferred. Any changes to the machine should be done in a deferred action. Note that deferred actions have limitations, particularly about which properties they can read (through MsiGetProperty or equivalent).
That brings us back to the question of what your custom action is attempting to do. By what you've asked, the direct answer is you need to mark it deferred. Doing so may require you to change its implementation. But more importantly, you should consider whether there are built-in Windows Installer means to accomplish what you want to accomplish, or ways that are built-in to the tool you're using (in this case InstallShield). If so, you should prefer using these built-in alternatives over writing your own, as it's very easy to write a custom action that does not handle every scenario it should.
回答2:
Michael Urman has provided a nice answer, but let me try with different words too, since this is a hard to comprehend topic. A few angles might be good. We also need an answer as to what it is that you actually need to do - generally a built-in MSI feature is better than a custom action. Really ;-).
The matter of fact answer is that you need a deferred mode custom action that is scheduled before CreateShortcuts, and after InstallFiles in the InstallExecuteSequence. At this location the files will be available on disk, and the shortcuts have not been created yet. However, there are several things that must be properly understood for this to be clear.
- The actions in the InstallExecuteSequence table are iterated twice for each install type (install, uninstall, modify, patch).
- The first run is immediate mode. All actions are inspected and run only if it is set to immediate mode. Immediate mode actions should inspect the system, gather information, set property values and not change anything on the system. They run with user rights. All other actions are written into an execution script to be run in deferred mode.
- The second run is deferred mode. Now the change script assembled by the first run is executed. No tables can be read and only a few properties can be accessed interactively. Every other property needed must be written into and available in the execution script. The actions may run with LocalSystem and can change anything on the system, or run with user rights if desired.
- The need to write properties into the deferred execution script and reading them back via the CustomActionData property concept greatly complicates things. The whole concept is best described in a separate article on the topic.
- Here is an older answer I wrote on a different site: forum.installsite.net/17211
- And have a read here too: https://docs.flexera.com/installshield25helplib/helplibrary/AccessingProps-DeferredCAs.htm?
来源:https://stackoverflow.com/questions/24242068/run-ca-after-installfile-and-before-createshortcuts