View Full Version : How do I dynamically set a variable to be used later?

P Frey
10-17-2001, 09:12 AM
This sounds like it should be a simple standard. How do I get Install Shield to ask me for a variable value which I can use later for file text replacement? Ex: What is your server name? Enter in svrx. Later in a file, replace XX_SERVER_NAME with svrx. I know how to do all but the initial variable question / set value.

10-18-2001, 08:20 AM
You could prompt the question through a Custom Action and store the answer in a txt file or registry.

04-23-2002, 04:01 PM
This should certainly be a feature request. I have run into this very problem and I have implemented one of Chandima's solutions (write a file and read it later).

It would be really nice to be able to set a property (simple name/value pairs) and get the value later -> e.g. Set it from one custom action which runs at initialization and then read it later to conditionally do something in another custom action.

Its not difficult to write to the file or registry, but you are then responsible for cleanup as well. Certainly not a very elegant solution.

04-24-2002, 10:33 AM
From a Custom Action DLL you can use

MsiSetProperty(hInstall, "MYNEWPROPERTY", value)

to create a new property, and then later use

MsiGetProperty(hInstall, "MYNEWPROPERTY", value, &len)

to get its value. See MSI Help.

04-24-2002, 10:35 AM
Does this only work with the "new" function prototypes for Custom Actions? Is there a way to get it if you are using old prototypes?

04-24-2002, 10:48 AM
I was asuming a New DLL interface so that you get
the handle to the MSI data. It seems fairly
straight forward to convert from the Classic to the New,
just use MsiGetProperty, or MsiGetTargetPath, and
then use MsiSetProperty and MsiSetTargetPath if something
needs to be updated. There may be a knowledge base
article on converting them as well.