CopyFile example

Product Feedback
Feedback

The following script is in the procedural format used in previous versions of InstallShield Professional. It will compile and run with no changes needed, and it correctly demonstrates the use of InstallScript functions. However, any script in this format does not use many new features of InstallShield Professional. These features, including automatic handling of common setup procedures and easy use of component-specific code, are available only with an event-based script defining event handler functions (as described in the Event Handlers topic and elsewhere in the documentation). The following script code can be incorporated in an event handler function.

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

 *

 * InstallShield Example Script

 *

 * Demonstrates the CopyFile function.

 *

 * This script copies files in the directory specified by 

 * SOURCE_DIR to the directory specified by TARGET_DIR.

 *

 * Note: Before running this script, you must set the 

 *       preprocessor constants to existing paths on

 *       the target system.

 *

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



#define  SOURCE_DIR "C:\\Source"

#define  TARGET_DIR "C:\\Target"



NUMBER nResult;



#include "ifx.h"

program



   // Specify source and target directories.

   SRCDIR    = SOURCE_DIR;

   TARGETDIR = TARGET_DIR;



   // Copy all files in the source directory, including files

   // in subdirectories, to the target directory.

   nResult = CopyFile("*.*", "*.*");



   // Report the results of the copy operation.

   switch (nResult)

      case 0:

         MessageBox ("Files successfully copied.", INFORMATION);



      case COPY_ERR_CREATEDIR:

         MessageBox ("A target directory could not be created.", SEVERE);



      case COPY_ERR_MEMORY:

         MessageBox ("Insufficient memory.", SEVERE);



      case COPY_ERR_NODISKSPACE:

         MessageBox ("Insufficint disk space.", SEVERE);



      case COPY_ERR_OPENINPUT:

         MessageBox ("Unable to open the input file(s) in "+ SRCDIR +".",
SEVERE);



      case COPY_ERR_OPENOUTPUT:

         MessageBox ("Unable to copy the source file(s).", SEVERE);



      case COPY_ERR_TARGETREADONLY:

         MessageBox (
            "A target file already exists and cannot be overwritten.", 
            SEVERE);



      default: 

         MessageBox ("An unspecified error occurred.", SEVERE);



   endswitch;



endprogram



// Source file: Is5fn198.rul