EzBatchAddPath Example

InstallShield 2016 » InstallScript Language Reference

Note • To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.

/*--------------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the EzBatchAddPath function.

*

* First, BatchSetFileName is called to change the default batch

* file to EXAMPLE_BATCH. Then EzBatchAddPath is then called to

* add C:\WINDOWS to the beginning of the PATH statement.  A

* second call to EzBatchAddPath adds C:\UTILS after the WINDOWS

* keyword in the PATH statement.

*

* Note: Before running this script, create a batch file

*       named ISExampl.bat and store it in the root of

*       drive C.

*

\*--------------------------------------------------------------*/

 

#define EXAMPLE_BATCH "C:\\ISExampl.bat"

#define TITLE "EzBatchAddPath example"

#define MSG   "Successful.\n\n%s added to %s statement."

 

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

 

export prototype ExFn_EzBatchAddPath(HWND);

 

function ExFn_EzBatchAddPath(hMSI)

    STRING szKey, szPath, szRefDir;

begin

 

    // Set the default batch file.

    BatchSetFileName (EXAMPLE_BATCH);

 

    // Set up parameters for next call to EzBatchAddPath.

    szKey      = "PATH";

    szPath     = "C:\\WINDOWS";

    szRefDir   = "";

 

    if (EzBatchAddPath (szKey, szPath, szRefDir, BEFORE) < 0) then

        // Report the error.

        MessageBox ("EzBatchAddPath failed.", SEVERE);

    else

 

        // Report success.

        SprintfBox (INFORMATION, TITLE, MSG, szPath, szKey);

 

        // Set up parameters for next call to EzBatchAddPath.

        szKey      = "PATH";

        szPath     = "C:\\UTILS";

        szRefDir   = "WINDOWS";

 

        if (EzBatchAddPath (szKey, szPath, szRefDir, AFTER) < 0) then

            // Report the error.

            MessageBox ("EzBatchAddPath failed.", SEVERE);

        else

            // Report success.

            SprintfBox (INFORMATION, TITLE, MSG, szPath, szKey);

        endif;

 

    endif;

 

end;