cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
anthonyw
Level 3

Accessing Install Location during Uninstall

Hello,

I was hoping that someone might be able to help me with accessing the application install location during an uninstall operation. From what I have read, the ARPINSTALLLOCATION property is set to the application install location via a custom action. I can see the custom action in the Sequences explorer so I am assuming that the property is being set. To access the property, I have tried using the MsiGetProductInfo method but I always get an empty string:

NUMBER nBufferSize;
NUMBER nResult;
STRING sProductCode[MAX_PATH];
STRING sInstallationDirectory[MAX_PATH];

nBufferSize = MAX_PATH;
nResult = MsiGetProperty(hMSI, "ProductCode", sProductCode, nBufferSize);

nBufferSize = MAX_PATH;
nResult = MsiGetProductInfo(sProductCode, INSTALLPROPERTY_INSTALLLOCATION, sInstallationDirectory, nBufferSize);

I have also tried accessing the property using the MsiGetProperty method but I still get an empty string:

NUMBER nBufferSize;
NUMBER nResult;
STRING sInstallationDirectory[MAX_PATH];

nBufferSize = MAX_PATH;
nResult = MsiGetProperty(hMSI, "ARPINSTALLLOCATION", sProductCode, nBufferSize);

I would appreciate if someone could explain to me what I am doing incorrectly. I am contemplating just accessing the InstallLocation registry value directly but I would like to use the MSI API if possible since it is the proper procedure.

Thanks in advance,

anthonyw
Labels (1)
0 Kudos
(1) Reply
anthonyw
Level 3

Hi,

Just thought that I'd follow up with what I discovered. My mistake was that I was using deferred execution for my custom action. So probably what was happening was that the install location no longer existed in the registry by the time my custom action was being executed. This was corrected by changing the custom action to immediate execution.

anthonyw
0 Kudos