Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Finding extracted files


10 replies to this topic

raza.ali@vyopta.com

raza.ali@vyopta.com
  • Full Members
  • 10 posts

Posted 19 February 2015 - 00:07

Apologies if this question is too basic or has been answered previously (I couldn't find it).

 

I'm trying to launch a config utility during the installation process, before the rest of the installation continues.

 

So as soon as the files are available in the TARGETDIR I would like to launch one of those files (the utility) let it do its job and then continue with the rest of the installation.

 

I wrote an install script and placed it in the sequence after "InstallFiles" step. The script does get called but it is not able to find the file. When I checked manually, the folders and files weren't there yet.

 

Please suggest how do I achieve the objective?

 

For your reference, I am including the script here:

 

szProgram = INSTALLDIR ^ "ConfigUtility.bat";

szCmdLine = szServiceUsername + "/" + szServicePassword;
 
if Is(FILE_EXISTS, szProgram) then  //this always returns false
         // Run the batch file.
         iRetVal = LaunchAppAndWait(szProgram, szCmdLine, LAAW_OPTION_WAIT); 
 
 
Thanks


deramor

deramor
  • Full Members
  • 187 posts

Posted 19 February 2015 - 00:14

I assume you wrote a custom action that calls an installscript function to do this.  Any CAs that are run during the execute sequence must be a deferred type.  When the installation passes into the execute sequence, it first reads in every action creating a script.  This also acts as a validation step.  If your CA is set to immediate, then when this script is created, the action will run.  However since the script is only being created and no system changes have been made (since no steps have been run) your files will not be on the system. 

 

Also note that access to properties are limited during deferred custom actions so if the values of szServiceUsername or szServicePassword are coming from properties, you will need to also save these values to the CustomActionData property and read them back inside the CA that uses them.



raza.ali@vyopta.com

raza.ali@vyopta.com
  • Full Members
  • 10 posts

Posted 19 February 2015 - 00:26

Thanks deramor. I'm trying to find how to "save these values to the CustomActionData property". Any pointers will be appreciated.



raza.ali@vyopta.com

raza.ali@vyopta.com
  • Full Members
  • 10 posts

Posted 19 February 2015 - 01:13

So I created a "Set a Property" custom action, and gave the property name as the InstallScript function name (from the script that is deferred). I sequenced the 'set-a-property' action to occur right before the deferred action.

 

Result: it's not even extracting files or creating any program directories. Something is failing but I don't know what.



ramyaraj

ramyaraj
  • Full Members
  • 6 posts

Posted 19 February 2015 - 05:08

Would it be possible to attach the installation log if you have one?


Regards,
Ramya Raj

raza.ali@vyopta.com

raza.ali@vyopta.com
  • Full Members
  • 10 posts

Posted 19 February 2015 - 15:45

Ok so now the files are being created and the bat file is also there but it doesn't look like its being invoked.

 

Here is the script (deferred action in current context):

 

////----------

export prototype StartConfigUtility(HWND);

 
function StartConfigUtility(hMSI)
    STRING  szServiceUsername, szProgram, szCmdLine;
    INT  iRetVal, iSize;
begin
 
  MsiGetProperty(hMSI, "CustomActionData", szServiceUsername, iSize);
 
  szProgram = INSTALLDIR ^ "ConfigUtility.bat";
 
  if Is(FILE_EXISTS, szProgram) then
     // Run the batch file.
     iRetVal = LaunchAppAndWait(szProgram, szServiceUsername, LAAW_OPTION_WAIT); // | LAAW_OPTION_HIDDEN);
  endif;
end;
 

////------

 

Properties on the StartConfigUtility custom action:

 

-- function name: StartConfigUtility

-- return processing: synchronous

-- in-script execution: deferred execution in system context

-- install exec sequence: After SetServiceAccountProperties

 

(absent from sequence in all other sequence types)

 

Custom Action: SetServiceAccountProperties

 

Propertyname: StartConfigUtility

--Property Value: [SERVICE_ACCOUNT_USERNAME];[SERVICE_ACCOUNT_PASSWORD]

--return processing: synchronous

--execution scheduling: always execute

--install exec sequence: After InstallFiles

 

(absent from sequence in all other sequence types)


Edited by raza.ali@vyopta.com, 19 February 2015 - 16:09.


deramor

deramor
  • Full Members
  • 187 posts

Posted 19 February 2015 - 22:25

If you can get the debugger to work and step into your code, I would do that to see what is going on.  Otherwise, you can use message boxes to help debug it.  It is possible that even INSTALLDIR is not defined when the script is run so your If(exists) may always fail.



raza.ali@vyopta.com

raza.ali@vyopta.com
  • Full Members
  • 10 posts

Posted 19 February 2015 - 23:47

You're right, INSTALLDIR is blank.

 

More worrying however is the fact that the entire custom action data is coming out to be blank:

 

////

MsiGetProperty(hMSI, "CustomActionData", szServiceUsername, iSize);

 
MessageBox(szServiceUsername, INFORMATION);
////
 
I see a message box with blank.
 
I modified Custom Action: SetServiceAccountProperties to include INSTALLDIR as well:

 

Propertyname: StartConfigUtility

--Property Value: [INSTALLDIR];[SERVICE_ACCOUNT_USERNAME];[SERVICE_ACCOUNT_PASSWORD]

 

Do you think including INSTALLDIR is causing this issue?



raza.ali@vyopta.com

raza.ali@vyopta.com
  • Full Members
  • 10 posts

Posted 20 February 2015 - 01:20

I am abandoning this path altogether. The effort is not worth the returns in my case.



deramor

deramor
  • Full Members
  • 187 posts

Posted 20 February 2015 - 17:07

In case you want to know my implementation of using the customactiondata property, I have included my getter and setter.

 

function CA_SetProperty(hMSI, sCustomActioName, sPropName)
    STRING sCAData, sPropValue;
    NUMBER nLength;
begin
    nLength = MAX_PATH;
    MsiGetProperty(hMSI, sPropName, sPropValue, nLength);
    
    nLength = MAX_PATH;
    MsiGetProperty(hMSI, sCustomActioName, sCAData, nLength);
    
    if (StrLength(sCAData) > 0) then
        sCAData = sCAData + "|";    
    endif;
    
    sCAData = sCAData + sPropName + "=" + sPropValue;
    MsiSetProperty(hMSI, sCustomActioName, sCAData);
    
end;

 

 

function CA_GetProperty(hMSI, sPropName, sPropValue)
    STRING sCAData, sPropPair, sName, sValue;
    NUMBER nResult, nLength;
    INT nMode;
    LIST listProps, listPropPair;
    LIST listPropNames;
    LIST listPropValues;
begin
    nLength = MAX_PATH;
    nResult = MsiGetProperty(hMSI, "CustomActionData", sCAData, nLength);
    if (nResult < 0) then
        //ReportError(hMSI, "The CustomActionData property does not exist.");
        return -1;
    else
        listProps = ListCreate (STRINGLIST);
        listPropNames = ListCreate (STRINGLIST);
        listPropValues = ListCreate (STRINGLIST);
        // Get each path from the search path into the list.
        if (StrGetTokens (listProps, sCAData, "|") < 0) then
            // Report the error.
            //ReportError(hMSI, "StrGetTokens on listProps failed.");
            return -1;
        else
            // Display the individual paths from the list.
            nResult = ListGetFirstString (listProps, sPropPair);
            // Loop while list items continue to be retrieved.
            while (nResult != END_OF_LIST)
                // Display the current element.
                listPropPair = ListCreate (STRINGLIST);
                if (StrGetTokens (listPropPair, sPropPair, "=") > 0) then
                    // Report the error.
                    //ReportError(hMSI, "StrGetTokens on ListPropPair failed.");
                    return -1;
                else
                    if (ListGetFirstString(listPropPair, sName) != END_OF_LIST) then
                        ListAddString(listPropNames, sName, AFTER);
                        if (ListGetNextString (listPropPair, sValue) == END_OF_LIST) then
                            sValue = "";
                        endif;
                            ListAddString(listPropValues, sValue, AFTER);
                        endif;
                endif;      
                ListDestroy(listPropPair);
                // Get the next string in the list.
                nResult = ListGetNextString (listProps, sPropPair);
            endwhile;
            endif;
        endif;
        // Remove the list from memory.
        ListDestroy (listProps);
    if (ListFindKeyValueString(listPropNames, listPropValues, sPropName, sPropValue) != 0) then
        return -1;
    endif;
    return 0;                         
end;

 

 

In order to use this code, somewhere before the installExecute sequence, I set all my properties.

 

Example:

 

CA_SetProperty(hMSI, "Your Custom Action Name", "YOURPUBLICPROPERTY");

 

Then in the deferred CA I get the value.

 

Example:  In the customer action that matches the above "Your Custom Action Name" I call

CA_GetProperty(hMSI, "YOURPUBLICPROPERTY", svSomeVariable);

 

I can now use the property in my CA.

 

If memory serves, only 3 properties are available to you in a deferred CA.  Only 1 is useful and that is CustomActionData.

Use it like a mailbox for data.



raza.ali@vyopta.com

raza.ali@vyopta.com
  • Full Members
  • 10 posts

Posted 20 February 2015 - 22:55

Thanks for all the help deramor. If I come back to this customization I'll surely try your suggestions.