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

INSTALLDIR and Repair/Modify

Hello all,

I think this question has been asked thousand times since 2000. Here is a new one.
I have an installation wich installs files and created several shortcuts in the start menu program group.
Everything works so far.
Now I repair the installation or modify it.
Everything works fine, except for one single shortcut chaiging its target.
Let's say, my installation creates two shortcuts:
1) [INSTALLDIR]\somesubfolder\some.pdf
2) [INSTALLDIR]\somesubfolder\somefolder\

Notice, that the first shortcut leads to a file, whereas the second to the folder.
After repair or reinstallation the first shortcut remains unchanged (correct), whereas the second becomes
C:\somesubfolder\somefolder\
which is wrong, since the initial application installation folder was not C:\ but rather some other location, let's say C:\Program Files\MyFolder.

All right, I know that INSTALLDIR value doesn't survive installation, that is it is set to default C:\ during Repair and/or Modify.
I have also read this ancient article:
http://www.installshield.com/news/newsletter/0305-articles/MsiPropUninst.asp
which means that I have to spend time storing and restoring value of the INSTALLDIR property manually.

I am using InstallShield 2009 Professional.
So the first question:
I thought there is already automatic mechanism that makes that stuff for me so that I don't need to reimplement it.

And the second:
Why the first shortcut remains correct and the second gets corrupted?

Thank you for your patience!
Labels (1)
0 Kudos
(1) Reply
Rothmansua
Level 3

The reason was really in the INSTALLDIR property not set during Repair/Modify.
The SetARPINSTALLLOCATION custom action was missing from the project and has not been added by the InstallShield during upgrade from previous InstalShield version.
The previous InstallShield versions set the condition for the SetARPINSTALLLOCATION property to Not Installed, what is not really correct. The IS 2009 correctly sets condition to empty (exec always) if I generate empty Basic MSI project.

The SetARPINSTALLLOCATION alone doesn't solve the issue. I had to add folllowing CA to set the INSTALLDIR on "Installed":

function SetInstallDir(hMSI)
INT nBuffer;
STRING svINSTALLDIR, svProductCode;
begin
nBuffer = MAX_PATH + 1;
MsiGetProperty(hMSI, "ProductCode", svProductCode, nBuffer);
MsiGetProductInfo(svProductCode, INSTALLPROPERTY_INSTALLLOCATION, svINSTALLDIR, nBuffer);
MsiSetProperty(hMSI, "INSTALLDIR", svINSTALLDIR);
end;


The pathes to single files seem to be stored by installer somehow, that's why the file shortcuts were not get corrupted during Repair/Modify. The shortcut to a folder gets constructed apparently anew, thus the wrong shortcut after Repair.
0 Kudos