1

I want to change the INSTALLDIR value for my Installer during Installation using Installscript. How should I do it? I have already tried the following: Created a custom action as:

function InitializeValues(hMSI)
    STRING svProductName; 
    STRING svInstallDir;  
    NUMBER nvSize;
begin                        
    nvSize=255; 
    MsiGetProperty (hMSI, "ProductName", svProductName, nvSize);  
    if(svProductName = "Notepad Pro") then  
         svInstallDir = PROGRAMFILES ^ svProductName;
 //     MsiSetTargetPath(hMSI,INSTALLDIR,svInstallDir);      
        MsiSetProperty(hMSI,INSTALLDIR,svInstallDir);
        MessageBox(INSTALLDIR,INFORMATION);
    endif;
end;

My custom action gets executed but the value of INSTALLDIR does not changes. I have scheduled my custom action in UI Sequence before Cost Finalize and in Execute Sequence After Cost Finalize.

Please help.

Mat
  • 202,337
  • 40
  • 393
  • 406
The King
  • 833
  • 1
  • 15
  • 41

1 Answers1

5

In both InstallUISequence and InstallExecuteSequence the custom action should run before CostFinalize. Also, MsiSetProperty is not used that way and I don't think it will work in InstallScript.

You can try using:

INSTALLDIR = svInstallDir

or

MsiSetProperty(hMSI, "INSTALLDIR", svInstallDir);
Cosmin
  • 21,216
  • 5
  • 45
  • 60