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 XCopyFile function.
*
* The first call to XCopyFile copies all text files,
* regardless of date, time, or version.
*
* The second call copies program files and creates the
* subdirectories that these files need to be located in.
*
* The third call copies template files based upon the date,
* writing over target files that have the same or earlier date
* as the source files.
*
* The fourth call copies sample files based upon the version
* number, writing over target files that have an older version
* number.
*
* Note: In order for this script to run correctly, you must
* set the preprocessor constants to a valid file name
* and path on the target system.
*
\*--------------------------------------------------------------*/
#define SDIR "C:\\ISExampl\\Source\\"
#define SDIR_PROGRAM "C:\\ISExampl\\Source\\Program\\"
#define SDIR_TEMPLATE "C:\\ISExampl\\Source\\Template\\"
#define SDIR_SAMPLES "C:\\ISExampl\\Source\\Samples\\"
#define TDIR "C:\\ISExampl\\Target\\"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_XCopyFile(HWND);
function ExFn_XCopyFile(hMSI)
STRING szSrcFile;
NUMBER nResult;
begin
// Set variable to filespec for source files.
szSrcFile = "*.txt";
// Copy all text files in the source directory
// into the target directory.
if (XCopyFile (SDIR ^ szSrcFile, TDIR ^ "*.*", COMP_NORMAL) < 0) then
MessageBox ("XCopyFile failed", SEVERE);
else
MessageBox ("Text files successfully copied.", INFORMATION);
endif;
// Set new variables.
szSrcFile = "*.*";
// Copy all program files in a source subdirectory to
// a subdirectory of the target directory.
if (XCopyFile (SDIR_PROGRAM ^ szSrcFile, TDIR ^ "PROGRAM" ^ "*.*",
INCLUDE_SUBDIR) < 0) then
MessageBox ("XCopyFile failed", SEVERE);
else
MessageBox ("Program files successfully copied.", INFORMATION);
endif;
// Copy all template files in a source subdirectory
// to a subdirectory of the target directory.
if (XCopyFile (SDIR_TEMPLATE ^ szSrcFile, TDIR ^ "TEMPLATE" ^ "*.*",
COMP_UPDATE_SAME | COMP_UPDATE_DATE) < 0) then
MessageBox ("XCopyFile failed", SEVERE);
else
MessageBox ("Template files successfully copied.", INFORMATION);
endif;
// Copy all sample files within a source subdirectory
// to a subdirectory of the target directory.
if (XCopyFile (SDIR_SAMPLES ^ szSrcFile, TDIR ^ "SAMPLES" ^ "*.*",
COMP_UPDATE_VERSION) < 0) then
MessageBox ("XCopyFile failed", SEVERE);
else
MessageBox ("Sample files successfully copied.", INFORMATION);
endif;
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |