View Full Version : Setting property value in correct upgrade sequence

03-01-2006, 03:40 PM
I've created a property called CHSHAREDDIR which I've used in a dialog to get the path to a shared folder. This value is saved to an XML file using 'System Configuration -> XML File Changes' and it all works fine.

The user of my application can change this value using the applications tools if they want to change the shared data path location and this new value is written back to the XML file.

When I perform an upgrade of the app I need to keep the new shared path value as, by default, the upgrade overwrites it with the original value that was selected by the user during the first install. E.g. if the user selects the folder 'c:\apps data' during the install then later, using the application, changes it to '\\server\data\application data', during the upgrade it gets changed back to 'c:\apps data'

I read the value using System Search and store it in the property called PREVIOUSCHSHAREDIR. Reading the value from the XML file works fine.

I've written the following InstallScript

function CheckPreviousSharedPath(hMSI)
string svValue;
number nSize;
if(MsiGetProperty(ISMSI_HANDLE, "PREVIOUSCHSHAREDIR", svValue, nSize) == ERROR_SUCCESS) then
if(StrLength(svValue) > 0) then
MsiSetProperty(ISMSI_HANDLE, "CHSHAREDDIR", svValue);

svValue = "";
MsiGetProperty(ISMSI_HANDLE, "CHSHAREDDIR", svValue, nSize);
MessageBox(svValue, INFORMATION);

A call to the code is placed in a custom action and when called the message box shows the correct path taken from the XML file.

However, nomatter where in 'Behavior and Logic -> Sequences' I place the action when the upgrade has finished the XML file shared path value always reverts back to the original path chosen by the user when they first installed the software.

It seems that the property CHSHAREDDIR is somehow set to the original value even though I set it to something different in the InstallScript.

Can someone please help or tell me what I'm doing wrong!!!!!