;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       Install() 
;; 
;;ACTION         Copies all files from SourcePath to DestinationPath 
;;               Insures pre-existing files are first removed. 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.0  - 2007/03/31 
;; 
;;History        1.0  - 2007/03/31 - Initial Release 
;; 
;;SYNTAX         Install(Sourcepath, DestinationPath) 
;; 
;;PARAMETERS     SourcePath - REQUIRED - String 
;;               - Name of Directory containing files to copy 
;;               DestinationPath - REQUIRED - String 
;;               - Directory where files will be installed 
;; 
;;REMARKS        Install locates the files in the SourcePath. For each file 
;;               found it first removes any read-only attribute and deletes  
;;               any file with the same name found in the destination directory. 
;;               It then copies the file to the destination folder. This insures 
;;               that the latest version of a file is installed. 
;; 
;;RETURNS        Array - List of files that failed to copy 
;; 
;;DEPENDENCIES   None 
;; 
;;TESTED WITH    NT4, W2K, WXP 
;; 
;;EXAMPLES       ; Copy files from the installation folder "System32" to the remote system 
;;               Copies files Install(".\system32", "\\server\c$\windows\system32") 
; 
Function Install($_SrcDir, $_DstDir)
 
  Dim $_FileName, $_RC, $_FList, $_EFlag, $_DC
 
  $_EFlag = 0
 
  ; Add trailing slashes if not provided 
  If Right($_SrcDir,1) <> '\'
    $_SrcDir = $_SrcDir + '\'
  EndIf
  If Right($_DstDir,1) <> '\'
    $_DstDir = $_DstDir + '\'
  EndIf
 
  $_FileName = Dir($_SrcDir + '*.*')
  While $_FileName <> '' And @ERROR = 0
 
  If Left($_FileName,1) <> '.'  ; process all but '.' and '..' 
 
      ; If the target file exists, remove all attributes and delete it 
      If Exist($_DstDir + $_FileName)
        $_RC = SetFileAttr($_DstDir + $_FileName, 0)
        Del $_DstDir + $_FileName
      EndIf
 
      ; Copy the new file to the destination 
      Copy $_SrcDir + $_FileName $_DstDir 
      If @ERROR <> 0
        $_EFlag = 1
        $_FList = $_FList + $_DC + $_Filename
        $_DC = ','
      EndIf
 
    EndIf
 
    $_FileName = Dir()
  Loop
 
  $Install = Split($_FList, ',')
  Exit $_EFlag
 
EndFunction