Monday, September 23, 2013

Set default installation directory for Dynamics GP in installscript

Installscript function
prototype setINSTALLDIR();
function setINSTALLDIR()   
string result;
string key1, key2;
string value;
number size;
number type;
string version;
begin
    //Change version to whatever version the installer is for  
    version = "v11.0";        

//this finds it in a 32-bit environment
    key1 = "SOFTWARE\\Microsoft\\Business Solutions\\Great Plains\\" + version + "\\1033\\DEFAULT\\SETUP";

//this finds it in a 64-bit environment
    key2 = "SOFTWARE\\Wow6432Node\\Microsoft\\Business Solutions\\Great Plains\\" + version + "\\1033\\DEFAULT\\SETUP";
    value = "AppPath";  
   
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    if(RegDBGetKeyValueEx(key1, value, type,result,size) = 0)then
        INSTALLDIR = result;
    elseif(RegDBGetKeyValueEx(key2, value, type,result,size) = 0)then
        INSTALLDIR = result;
    endif;
end;

Call it from OnFirstUIBefore, for example:
function OnFirstUIBefore( )

    NUMBER nResult, nSetupType;
    STRING szTitle, szMsg, svName, svCompany, svSerial;
    STRING szDir, strNum;
    BOOL bLicenseAccepted;

begin

    nSetupType = TYPICAL;  
    setINSTALLDIR();
    szDir = INSTALLDIR;
    svName    = "";
    svCompany = "";
...

No comments:

Post a Comment

There was an error in this gadget