Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Please help: pass param value to custom action


1 reply to this topic

aussie

aussie
  • Members
  • 2 posts

Posted 10 February 2004 - 05:45

Dear all,

Please Help!

I'm building my install using the InstallShield Professional - Windows Installer Edition.

What I'm trying to do is pretty simple:
1. get the user to enter a text input,
2. once the install copies the files to the destination directory, it will modify one of the files by adding the user input.

To achive point 1 above, I've written one custom action that uses AskText standard dialog box, and sets a property using MsiSetProperty(hMSI, "MYINPUT", svValue). I then put this custom action in a right order in the User Interface sequences. As much as I can see, this works as desirable (ie. it prompts the user at the right time and sets the property correctly).

To achive point 2, I've written yet another custom action to modify a file _after_ the install copies such file over. Because of this, I made the custom action to have "Defered Execution" for the In-Script Execution option. However, I'm having difficulties getting back my property using MsiGetProperty(hMSI, "MYINPUT", foe1, foe2). That is, it always return nothing.

Changing the "Defered Execution" to "Immediate execution" will give me the right value of the property, but the problem is that it will be executed _before_ the file is copied.

Does anyone have any suggestion? Am I in the wrong track here?

Thanks in advance.

Set.





hteichert

hteichert
  • Members
  • 158 posts

Posted 10 February 2004 - 10:48

It's a very old question being answered already several times here in the forum.
So let's repeat it again:

Taken from MS's Windows installer documentation, page "Obtaining Context Information for Deferred Execution Custom Actions":
"Because the installation script can be executed outside of the installation session in which it was written, the session may no longer exist during execution of the installation script. This means that the session handle and property data set during the installation sequence are not available to a deferred execution custom action."

Windows installer will give you the value of one property in your CA: "CustomActionData"

So what to do:
You have to take two steps to bring data to your CA (let's call it "MyDeferredCA"), the data you want shall be in property "MYINPUT":
1. Write a CA of type 51 which transfers the required data to a property named as your deferred CA (in our example "MyDeferredCA"):
Source: MyDeferredCA
Type: 51
Target: [MyData] (the required data as formatted text)
Include this CA in the execute sequence before your "real" CA.
2. Access your data in your CA ("MyDeferredCA") by using the propertyname "CustomActionData" instead of "MYINPUT"

If you want to transfer more data to your CA, you have to put it all in one property (named as your deferred CA) and access this data in your deferred CA by getting the property "CustomActionData" and splitting it into the different parts in your deferred CA.

Further info can by found in this forum by searching for "CustomActionData".
Another good description how to do it can be found at Installshield Knowledgebase Q104413.
h.teichert-ott