cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tier_3
Level 4

InstallScript MsiGetProductInfo returns error 243 ERROR_MORE_DATA when INSTALLPROPERTY_INSTALLLOCATION property value is more than 37 characters

I have a msi installer package and when I do a Major Upgrade the default install path is displayed. I want to be able to detect the previous install location and set it as the InstallDir property during Major Upgrade.

I've set up a function in InstallScript which uses MsiGetProductInfo() to get the previous install location from INSTALLPROPERTY_INSTALLLOCATION property and set it up as a custom action that runs after CostFinalize for condition IS_MAJOR_UPGRADE.

The below code works for a previous install path that is 37 characters or less.

eg This works C:\123456789012345678901234567890123\

NUMBER nBufferSize;
NUMBER nResult;
STRING sPCode[MAX_STRING];
STRING sInstallationDirectory[9999];
STRING sResult[MAX_STRING];

begin

	nBufferSize = 9999999;
	MsiGetProperty(hMSI,"MIGRATE",sPCode,nBufferSize);
	MessageBox(sPCode,INFORMATION);

	nResult = MsiGetProductInfo(sPCode, INSTALLPROPERTY_INSTALLLOCATION, sInstallationDirectory,nBufferSize);
 
        NumToStr(sResult,nResult);
    	MessageBox("Result:"+sResult,SEVERE);
	MessageBox("INSTALLDIR:"+sInstallationDirectory,SEVERE);
	MsiSetProperty(hMSI, "INSTALLDIR", sInstallationDirectory);
end;

When the previous install path is 38 characters or more it will return an empty string and the error code 234 ERROR_MORE_DATA.

I've increased the buffer to a large value and it still doesn't work.
I'm using installshield 2019 professional, anyone know why this is happening?


0 Kudos

(2) Replies
banna_k
Revenera
Revenera

Hi @tier_3 

 

According to Microsoft, "BufferSize" variable will be updated with the new size during the ERROR_MORE_DATA, check what size is returned. more information can be found at the below link:

https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetproductinfoa 

As well see the below thread, which mentioned to configure the custom action to  immediate execution to get the values:

https://community.flexera.com/t5/InstallShield-Forum/Access-INSTALLDIR-from-deferred-execution-during-uninstall/m-p/24172

 

0 Kudos

Hi @banna_k 

I printed out the "BufferSize" value for the case where the path is C:\1234567890123456789012345678901234\ and it returned as 38. Which is exactly the number of characters of the path but I'm still getting error 234 which is ERROR_MORE_DATA.

My custom action is defintely set to "immediate Execution".

Any other ideas? Thanks.

0 Kudos