PathMove Example

InstallShield 2022 ยป InstallScript Language Reference

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 PathMove functions.

*

* This example script shows how to reposition paths in the path

* buffer.  It begins by initializing the path buffer with a

* search path.  Then, it moves one path ahead of another.

* Next, it gets the modfied search path from the search buffer

* and displays it.

*

* It then initializes the path buffer with the modified search

* path and moves one path after another path.  Finally, it gets

* the modfied search path from the search buffer and displays

* it.

*

* Note: PathGet is called after the first PathMove statement

*       only so the value of the path buffer can be displayed

*       for demonstration purposes.  In a production script,

*       you would finish building the search path in the buffer

*       before calling PathGet.

*

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

 

#define TITLE "Path buffer example"

 

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

#include "Ifx.h"

 

export prototype ExFn_PathMove(HWND);

 

function ExFn_PathMove(hMSI)

    STRING svSearchPath;

begin

 

    // Set up the search path to pass as a parameter to PathSet.

    svSearchPath = "C:\\MsOffice;C:\\DOS;C:\\Windows;C:\\App2;C:\\Temp";

 

    // Initialize the path buffer.

    PathSet (svSearchPath);

 

    // Display the initial search path.

    SprintfBox (INFORMATION, TITLE,

               "The starting search path is %s.",svSearchPath);

 

    // Move C:\App2 before C:\DOS.

    if (PathMove("C:\\App2", "C:\\DOS", FULL, FULL, BEFORE) < 0) then

        MessageBox ("Unable to move C:\\App2.", SEVERE);

        abort;

    endif;

 

    // Get the search path from the path buffer and release

    // the memory allocated for the path buffer.

    PathGet (svSearchPath);

 

    // Display the search path.

    // svSearchPath will contain C:\MSOFFICE;C:\APP2;C:\DOS;C:\WINDOWS;C:\TEMP

    SprintfBox (INFORMATION, TITLE,

               "C:\\App2 moved before C:\\DOS.\n\nThe search path is %s.",

               svSearchPath);

 

    // Initialize the path buffer with the search path.

    PathSet (svSearchPath);

 

    // Move C:\DOS after C:\Temp.

    if (PathMove ("C:\\DOS", "TEMP", FULL, PARTIAL, AFTER) < 0) then

        MessageBox ("Unable to move C:\\DOS.", SEVERE);

    endif;

 

    // Get the search path from the path buffer and release

    // the memory allocated for the path buffer.

    PathGet (svSearchPath);

 

    // Display the search path.

    // svSearchPath will contain C:\MSOFFICE;C:\APP2;C:\WINDOWS;C:\TEMP;C:\DOS

    SprintfBox (INFORMATION, TITLE,

               "C:\\DOS moved after C:\\Temp.\n\nThe search path is %s.",

               svSearchPath);

 

end;