View Full Version : Set/Get Property Problem

Dan Crosby
06-03-2005, 08:16 AM
In OnFirstUIBefore I set some property values:

svServerName = svMachineName + svInstanceName;
SetProperty("REMOTESERVERNAME", svServerName);

SetProperty("IS_SQLSERVER_SERVER", svServerName);
SetProperty("IS_SQLSERVER_USERNAME", svUserName);
SetProperty("IS_SQLSERVER_PASSWORD", svUserPassword);

From OnFirstUIAfter I call another function, ConfigSQL, and try to retrieve
the property values, but all I get are blanks (the default values of the properties in the Property Manager).

Is there some sort of scoping issue here? (ConfigSQL is in a different RUL file)


Christopher Painter
06-03-2005, 09:13 AM
ISScript doesn't have a native SetProperty function. Is this a custom wrapper function for MSISetProperty that you wrote? If so, can we see what it looks like?

Also depending on the execution context of your custom action you may not have access to all of the MSI properties at runtime. I only do Basic MSI projects these days but I don't think it should be an issue for OnFirstUIBefore.

Dan Crosby
06-10-2005, 04:18 AM
// SetProperty function

function INT SetProperty(szPropertyName, szPropertyValue)
nRet = MsiSetProperty(ISMSI_HANDLE, szPropertyName, szPropertyValue);
return nRet;

Christopher Painter
06-10-2005, 07:09 AM
What value gets assigned to nRet when you set a function? Also when you run an MSI log file, what value do you see assigned to the property?

Dan Crosby
06-10-2005, 10:35 AM

The 'SetProperty' works fine... I confirmed this by immediately doing a 'GetProperty' after them. I also note that my SQL script properly installs and creates my database on the correct SQL server (the MSDE I just installed).

The problem definitely lies in my 'ConfigSQL' function, which is trying to add a user to the SQL database. In that function, the 'GetProperty' just doesn't work. Do properties get reset to their default values for any reason?

I can't see anything untoward in the MSI log file (which I've attached).

Any thoughts?



Dan Crosby
06-13-2005, 07:12 AM
I'm starting to think this is actually a bug rather than InstallShield's typical opaqueness. I can't find an explanation anywhere for why it shouldn't work...

06-13-2005, 09:44 AM
So rather then just discounting someone's suggestion, why don't you actually try using the MsiGetProperty and MsiSetProperty calls to see if they work?

06-13-2005, 09:47 AM
Could you post the code for your GetProperty function?

In general, properties are reset only when execution switches from the UI sequence to the Execute sequence, and this just for private properties (or public properties under low-privilege situations, in which case SecureCustomProperties can help). Also control events and custom actions can unset/reset properties, but if you don't have anything like that...

Dan Crosby
06-13-2005, 10:02 AM
Eh? Whose suggestion did I discount? I am using MsiGetProperty and MsiSetProperty...

My GetProperty function:

// GetProperty function

function STRING GetProperty(szPropertyName)
STRING szValue;
NUMBER nRet, nvSize;
nvSize = 256;
nRet = MsiGetProperty(ISMSI_HANDLE, szPropertyName, szValue, nvSize);
return szValue;

What is the Execute sequence? I am trying to run my 'GetProperty's after the installation, so that my MSDE is running and the database has been installed from the SQL script (so I can add a user to the database). Does that make a difference?

Christopher Painter
06-13-2005, 10:07 AM
Guys, we don't need to fight here, forget it.

Read these pages and follow up with any questions:



Dan Crosby
06-14-2005, 04:59 AM
I've created a very simple example of my problem.

In OnFirstUI before I set MYPUBLICPROP to a value ("Testing, Testing 1-2-3"),
I then (immediately) do a MsiGetProperty and MessageBox to show that the value has been correctly set in the property.

However, when I do the same MsiGetProperty in OnFirstUIAfter, the value returned from the property is "Default Value" (which is, unsurprisingly, the default value in the property manager).

Am I missing something, or should this work?

06-14-2005, 09:42 AM

I just got bit by this, so I figured I'd send it along as something to check:

Check the error flag returned by MsiGetProperty. If it's ERROR_MORE_DATA then your buffer is not large enough. Also, I found this in the remarks section: "If the value for the property retrieved by the MsiGetProperty function is not defined, it is equivalent to a 0-length value. It is not an error."

On that note, if you call MsiSetProperty and pass in an empty string as the value of the property, the property is actually deleted and NOT set to an empty string.

Anyway, like I said, not sure if any of this will help, but I just got bit by it so I figured I'd pass it along. Hope it helps.