Is Example

InstallShield 2018 » 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 Is function.

*

* The Is function is first called to check if a file is write

* protected.  It is called a second time to check if the

* directory is write protected.  This is useful for checking

* the write protection of directories on a network. The third

* time the Is function is called, the function checks if Windows

* is installed on a network server or if it is installed on the

* local system.

*

* Note: Before running this script, set the defined constants

*       so that they point to an existing file on the target

*       system.

*

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

 

#define EXAMPLE_DIR   "C:\\WINDOWS"

#define EXAMPLE_FILE  EXAMPLE_DIR^"Win.com"

#define TITLE         "Is Example"

 

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

#include "Ifx.h"

 

export prototype ExFn_Is(HWND);

 

function ExFn_Is(hMSI)

     NUMBER nResult;

begin

 

    // Check if the EXAMPLE_FILE file is write-protected.

    nResult  = Is (FILE_WRITEABLE, EXAMPLE_FILE);

 

    // Report the results.

    if (nResult = TRUE) then

        SprintfBox (INFORMATION, TITLE, "%s is writeable.", EXAMPLE_FILE);

    elseif (nResult = FALSE) then

        SprintfBox (INFORMATION, TITLE, "%s is not writeable.", EXAMPLE_FILE);

    else

        SprintfBox (INFORMATION, TITLE,

                   "Unable to determine if %s is writeable.", EXAMPLE_FILE);

    endif;

 

    // Check if the directory is write-protected.

    nResult  = Is (DIR_WRITEABLE, EXAMPLE_DIR);

 

    // Report the results.

    if (nResult = TRUE) then

        SprintfBox (INFORMATION, TITLE, "%s is writeable.", EXAMPLE_DIR);

    elseif (nResult = FALSE) then

        SprintfBox (INFORMATION, TITLE, "%s is not writeable.", EXAMPLE_DIR);

    else

        SprintfBox (INFORMATION, TITLE,

                   "Unable to determine if %s is writeable.", EXAMPLE_DIR);

    endif;

 

    // Check if Windows is being shared on a network.

    nResult  = Is (WINDOWS_SHARED, "");

 

    // Report the results.

    if (nResult = TRUE) then

        MessageBox ("Windows is shared.", INFORMATION);

    elseif (nResult = FALSE) then

        MessageBox ("Windows is not shared.", INFORMATION);

    else

        MessageBox ("Unable to determine if Windows is shared.", SEVERE);

    endif;

 

end;