; +-------------------------------------------------------------------------------------------------------+ ; | Function : Synchronization Script | ; | Company : Lindeberg IT Solutions | ; | Author : Stigter A.E. | ; +-------------------------------------------------------------------------------------------------------+ ; | Requirements : Kix4.50 or greater & KixForms.DLL 2.46.x | ; +-------------------------------------------------------------------------------------------------------+ ; | Version history: | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | Date | Version | Updated by | Action | Comments | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 23-03-2006 | 1.0 | StigterA | Release | Initial Version release | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 08-05-2006 | 1.1 | StigterA | Update | Added logfile selection | | ; | | | | | | Added Timer | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 28-08-2006 | 1.2 | StigterA | Update | Added about box | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 31-08-2006 | 1.21 | StigterA | Fix | Fixed colour of some forms | | ; | | | | | | Abort GUICopy implemented | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 20-09-2006 | 1.22 | StigterA | Update | Added activity light button | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 10-11-2006 | 1.23 | StigterA | Update/ | Added No Inventory option. | | ; | | | | | Fix | Added Native Copy (KIX) mode option. | | ; | | | | | | Fixed Current time update frequency. | | ; | | | | | | Fix file size reported 0 if smaller than the | | ; | | | | | | format (1024 for KB etc..) | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 15-12-2006 | 1.24 | StigterA | Fix | Fixed the Kixforms.dll registration routine. | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 18-12-2006 | 1.25 | StigterA | Fix | Fixed destination to be a subfolder from source. | | ; | | | | | | This resulted in a recursive error! (Path to long) | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 05-01-2007 | 1.26 | StigterA | Fix | Fixed not re-enabling the logfile button. | | ; | | | | | | Fixed GUICopy routine always waiting for abort when | | ; | | | | | | destination was missing after copy. | | ; | | | | | | Time limit set to 1500 ms. | | ; | | | | | | Added disable logging when more then | | ; | | | | | | will be copied. | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; | | 12-01-2007 | 1.27 | StigterA | Update | Added /min as a command line switch. | | ; | | | | | | This will run in 'minimal' mode conserving memory. | | ; | | | | | | This mode disables Inventory & Logging. | | ; | +------------+---------+------------+---------+-----------------------------------------------------+ | ; +-------------------------------------------------------------------------------------------------------+ ;****************************************************************************** ;================================[ Settings ]================================== ;****************************************************************************** ; +-------------+ ; | Kix Options | ; +-------------+ Break On ;$=SetOption("Explicit","On") ; +--------------------------+ ; | Declare Global Variables | ; +--------------------------+ ; -- Counters -- Global $FileNrAdd, $DirNrAdd, $FileNrChecked, $FileNrRem, $DirNrRem, $FileSizeTot,$FileSizeChecked Global $FileErr, $DirErr, $PreviousTick, $MaxFiles ; -- Environment Variables -- Global $TmpDir, $SystemDrive, $SysRoot, $WinDir, $SysDir, $ComSpec, $CurDir ; -- Script Variables -- Global $ScrVer, $ScrDate, $ScrAuthor, $ScrCompany, $AutoMode, $CopyMode, $NoSpace, $About_Message Global $LastFolderAdded, $ScrParameters, $ScrKixForms, $DelayTime, $ProgBarInc, $LogFile Global $ProgBarCount, $PorgBarMax, $ScrTitle ; -- Kixform Variables -- Global $System, $FormSync, $B_Loc_Source, $B_Loc_Destination, $CB_Opt_SubFldrs, $CB_Opt_Source, $CB_opt_NoSync, $CB_Opt_FastSync, $CB_Opt_Log, $B_Con_Start, $B_Con_Stop, $TB_Timers_Start, $TB_Timers_Start_Value, $TB_Timers_Done, $TB_Timers_Done_Value, $TB_Info_Check_ftc, $TB_Info_Check_ftc_Value, $TB_Info_Check_TotalSize, $TB_Info_Check_TotalSize_Value, $TB_Info_Current_Fc, $TB_Info_Current_fc_Value, $TB_Info_Current_TotalSize, $TB_Info_Current_TotalSize_Value, $TB_Free_Disk, $TB_Free_Disk_Value, $PB_Bar_Progress, $LV_His, $LV_Fail, $LV_FastSync, $TB_Loc_Source, $TB_Loc_Destination Global $FormInv, $PB_Inventory, $TB_Message Global $FormLog, $TB_Log_Message, $PrB_log ; -- System Variables -- Global $objShell, $objFSO ; -- Dummy Variable -- Global $rc ; -- Led Color Variables -- Global $IGreen, $IBlue, $IRed, $IBlack, $IYellow ; +------------------------+ ; | Define Variable Values | ; +------------------------+ ; -- Environment Variables -- $TmpDir = ExpandEnvironmentVars("%TEMP%") $SystemDrive = ExpandEnvironmentVars("%SYSTEMDRIVE%") $SysRoot = ExpandEnvironmentVars("%SYSTEMROOT%") $WinDir = ExpandEnvironmentVars("%WINDIR%") $SysDir = $WinDir + "\System32" $ComSpec = ExpandEnvironmentVars("%COMSPEC%") $CurDir = @CURDIR ; -- Led Colors -- $IGreen = 34 $IBlue = 35 $IRed = 33 $IBlack = 32 $IYellow = 53 ; -- Script Variables -- $ScrTitle = "LBCopy" $ScrVer = "v1.27" $ScrDate = "12-01-2007" $ScrAuthor = "Stigter A.E." $ScrCompany = "Lindeberg IT Solutions" $DelayTime = 800 $MaxFiles = 350000 $LogFile = "" $ScrParameters = 'Valid Parameters are :' + @CRLF + '/s=Source Folder' + @CRLF + '/d=Destination Folder' + @CRLF + '/nosub -> Enables the "No SubFolders" option' + @CRLF + '/nosync -> Enables the "No Synchronization" option' + @CRLF + '/nosrc -> Enables the "No Source Update" option' + @CRLF + '/fastsync -> Enables the "Fast Sync" option' + @CRLF + '/noinv -> Enables the "No Inventory" option' + @CRLF + '/native -> Uses the native KIX copy function' + @CRLF + '/addlast -> Adds last folder from source to destination' + @CRLF + '/nospace -> Continue if not enough space on destination (unattended mode)' + @CRLF + '/nolog -> Disable all logging (only onscreen error logging remains)' + @CRLF + '/min -> Same as /noinv, /nolog & /native combined' + @CRLF + '/log -> Logs the progress to a file in the temp folder' + @CRLF + '/log=Logfile -> Logs the progress to the defined file' + @CRLF + '/? -> Shows this message box' + @CRLF + @CRLF + 'Example:' + @CRLF + '$ScrTitle /s=C:\Temp Folder /d=D:\Temp Folder /fastsync /log' + @CRLF + @CRLF + 'Important Note(s):' + @CRLF + ' - The options NoSync & FastSync cannot be used together!' + @CRLF + ' - The option NoInv cannot be used with NoSync or Fastsync!' $ScrKixForms = @CRLF + @CRLF + "The file Kixforms.dll can be downloaded." + @CRLF + "Please check the following site :" + @CRLF + "http://www.kixforms.org OR http://www.kixtart.org" + @CRLF + "Download either the DLL file or the MSI file (Windows Installer)." + @CRLF + "The registration (Regsrv32) of the DLL file is needed." + @CRLF + "This will be done automatically by the script." + @CRLF + "If the MSI file is used, this will be done automatically." $About_Message = "Title : $ScrTitle " + $ScrVer + " (Date:" + $ScrDate + ")" + @CRLF + "Author : " + $ScrAuthor + @CRLF + "Company : " + $ScrCompany + @CRLF + "Function : " + @CRLF + "This script has been developed to overcome some" + @CRLF + "problems with the normal explorer copy function and" + @CRLF + "to help keeping files/folders in sync." + @CRLF + @CRLF + "COPY:" + @CRLF + "The copy function of this script will not abort if a" + @CRLF + "problem occurs during copying. (unlike the explorer that" + @CRLF + "leaves you in the dark about what was copied and what not)." + @CRLF + @CRLF + "SYNC:" + @CRLF + "This script has several synchronization options to keep your" + @CRLF + "files in sync." + @CRLF + "Please note that it is not a FULL sync (it does not remove" + @CRLF + "any files) but it syncs the SOURCE to the DESTINATION in which" + @CRLF + "the SOURCE is leading." + @CRLF + "Files that are newer in the DESTINATION can be synchronized" + @CRLF + "back to the SOURCE if needed." + @CRLF + @CRLF + "UNATTENDED:" + @CRLF + "Here is a list of command line switches" + @CRLF + $ScrParameters ;============================================================================== ;===============================[ Main ]======================================= ;============================================================================== ; -- Initialize Script -- Init() ; -- Show Form -- $FormSync.ShowModal ; -- Start Program -- If $AutoMode = 0 ; -- Attended Mode -- While $FormSync.Visible $rc=Execute($FormSync.DoEvents()) Loop Else ; -- Unattended Mode -- AddLastFldr() Start($TB_Loc_Source.Text, $TB_Loc_Destination.Text) EndIf ; -- Quit Script -- Quit ;============================================================================== ;===============================[ Functions ]================================== ;============================================================================== ; +-[Name]-----------------+ ; | Function Parameters() | ; +-[Comment]--------------+-----------------------------------------------------+ ; | This function checks if the script is started with command line options. | ; | A dialog will be shown if the parameters are not correct. | ; | This will only work if the script has been compiled into an executable. | ; | This can be done with a tool like KiXscripts Editor 1.7 or Higher. | ; +------------------------------------------------------------------------------+ ; | Parameters that can be used are : | ; | /s=source folder /d=destination folder /nosub /nosync /nosrc /fastsync /log | ; +------------------------------------------------------------------------------+ Function Parameters() Dim $Args, $ArgsNr, $ArgOk, $x, $SrcDst, $Arg, $Help ; -- Retreive Script Parameters -- If $ExeCmdLine $Args = Split(Lcase($ExeCmdLine), "/") $ArgsNr = Ubound($Args) ; -- Remove any trailing spaces -- For $x = 1 To $ArgsNr If InStrRev($Args[$x], " ") = Len($Args[$x]) $Args[$x] = SubStr($Args[$x], 1, Len($Args[$x])-1) EndIf Next ; -- If more than one argument analyze -- If $ArgsNr >= 1 ; -- Parameters Found -- $x = 1 $Help = 0 While $x <= $ArgsNr ; -- Remove any " found in the parameter -- $Arg = Replace($Args[$x], Chr(34), "") ; -- Set Parameters in script -- Select Case $Arg = "nosub" $CB_Opt_SubFldrs.Checked = 1 Case $Arg = "nosync" $CB_Opt_NoSync.Checked = 1 Case $Arg = "nosrc" $CB_Opt_Source.Checked = 1 Case $Arg = "fastsync" $CB_Opt_FastSync.Checked = 1 Case $Arg = "noinv" $CB_Opt_NoInventory.Checked = 1 Case $Arg = "native" $CB_Opt_NativeCopy.Checked = 1 Case $Arg = "addlast" $CB_Opt_AddLast.Checked = 1 Case $Arg = "min" $CB_Opt_NoInventory.Checked = 1 $CB_Opt_NoLog.Checked = 1 $CB_Opt_NativeCopy.Checked = 1 Case $Arg = "nospace" $NoSpace = 1 Case $Arg = "nolog" $CB_Opt_NoLog.Checked = 1 Case $Arg = "log" $CB_Opt_Log.Checked = 1 Case $Arg = "?" $Help = 1 Case 1 ; -- Check for option values -- $SrcDst = Split($Arg, "=") If VarType($SrcDst) >= 8192 If Ubound($SrcDst) >= 1 Select Case $SrcDst[0] = "s" ; -- Source Folder -- $TB_Loc_Source.Text = $SrcDst[1] Case $SrcDst[0] = "d" ; -- Destination Folder -- $TB_Loc_Destination.Text = $SrcDst[1] Case $SrcDst[0] = "log" ; -- Log File -- $CB_Opt_Log.Checked = 1 $LogFile = $SrcDst[1] $B_Opt_Log.Text = Split($LogFile, '\')[Ubound(Split($LogFile, '\'))] EndSelect EndIf EndIf EndSelect $x = $x + 1 Loop ; -- Check Mandatory Parameters -- If ($TB_Loc_Source.Text = "") OR ($TB_Loc_Destination.Text = "") OR ($Help = 1) OR (($CB_Opt_FastSync.Checked <> 0) AND ($CB_Opt_NoSync.Checked <> 0)) OR (($CB_Opt_NoInventory.Checked <> 0) AND (($CB_Opt_FastSync.Checked <> 0) OR ($CB_Opt_NoSync.Checked <> 0))) $rc=MessageBox($ScrParameters, "Valid script parameters", 48) ; -- Quit Script -- Quit Else ; -- Disable Logging if this option is enabled -- If $CB_Opt_Nolog.Checked <> 0 $CB_Opt_Log.Enabled = 0 $CB_Opt_Log.Checked = 0 $B_Opt_Log.Enabled = 0 $LV_His.Enabled = 0 EndIf ; -- Running Script in Unattended -- Progress("Command line switches where passed and are now being implemented.") $AutoMode = 1 EndIf EndIf Else ; -- Running Script in Attended Mode -- Progress("No command line switches where passed.") $AutoMode = 0 EndIf EndFunction ; +-[Name]------------------+ ; | Function AddLastFldr() | ; +-[Comment]---------------+---------------------+ ; | Add the last source folder to the destination | ; +-----------------------------------------------+ Function AddLastFldr() Dim $Fldrs, $LastFldr ; -- Check if last Source char is \ -- If InStrRev($TB_Loc_Source.Text, "\") = Len($TB_Loc_Source.Text) ; -- Remove last \ -- $TB_Loc_Source.Text = SubStr($TB_Loc_Source.Text, 1, Len($TB_Loc_Source.Text)-1) EndIf $Fldrs = Split($TB_Loc_Source.Text, "\") If Ubound($Fldrs) >= 1 $LastFldr = $Fldrs[Ubound($Fldrs)] ; -- CheckBox State -- If $CB_Opt_AddLast.Checked <> 0 $LastFolderAdded = 1 ; -- Check if last Destination char is \ -- If InStrRev($TB_Loc_Destination.Text, "\") <> Len($TB_Loc_Destination.Text) ; -- Add last \ -- $TB_Loc_Destination.Text = $TB_Loc_Destination.Text + "\" EndIf $TB_Loc_Destination.Text = $TB_Loc_Destination.Text + $LastFldr Progress("Last Source Folder added to Destination : " + $TB_Loc_Destination.Text) Else $Fldrs = Split($TB_Loc_Destination.Text, "\") If $LastFldr = $Fldrs[Ubound($Fldrs)] AND $LastFolderAdded = 1 ; -- Remove Last Folder -- $LastFolderAdded = 0 $TB_Loc_Destination.Text = Join($Fldrs, "\", Ubound($Fldrs)) Progress("Last Source Folder removed from Destination : " + $TB_Loc_Destination.Text) EndIf EndIf EndIf EndFunction ; +-[Name]-----------+ ; | Function Init() | ; +-[Comment]--------+--------------------------+ ; | Initialize some settings used in the script | ; +---------------------------------------------+ Function Init() Dim $ShellVer ; -- Create Shell Object for Global use -- $objShell = CreateObject("Shell.Application") ; -- Create FileSystem Object for Global use -- $objFSO = CreateObject("Scripting.fileSystemObject") ; -- Initialize Forms -- Form_Init() ; -- Load Forms -- SyncForm() InvForm() WriteLogForm() Progress("Forms initialized and loaded...") ; -- Retreive Parameters -- Parameters() ; -- Initialize GUICopy Function -- $ShellVer = GetFileVersion($SysDir + "\Shell32.dll", "FileVersion") Progress("Check version of file " + $SysDir + "\Shell32.dll") If $ShellVer >= "4.71" ; -- Use GUI Copy Function -- $CopyMode = 1 Progress("Version is same or higher (" + $ShellVer + ") than the required 4.71" ) Progress("Copy with progress indicator enabled.") ; -- Enable Native Copy function -- $CB_Opt_NativeCopy.Enabled = 1 ; -- Check for unattended mode with native copy enabled -- If ($AutoMode = 1) AND ($CB_Opt_NativeCopy.Checked <> 0) $CopyMode = 0 EndIf Else $CopyMode = 0 Progress("Version is lower (" + $ShellVer + ") than required 4.71" ) Progress("Copy with progress indicator disabled - using native copy function.") ; -- Uncheck & disable Native Copy mode -- $CB_Opt_NativeCopy.Checked = 0 $CB_Opt_NativeCopy.Enabled = 0 EndIf ; -- Set NoSpace option default to 'off' -- $NoSpace = 0 EndFunction ; +-[Name]--------------+ ; | Function GUICopy() | ; +-[Comment]-----------+--------------------------------------------------------------------------------+ ; | This function opens a Folder browser window | ; +------------------------------------------------------------------------------------------------------+ ; | Author Christopher Shilt | ; | Action Uses the Shell Object to copy or move files/folders. Displays the animated | ; | 'Copying Files' progress dialog as files/folders are being copied. | ; | Syntax GUICopy("Source", "Destination", optional FLAGS, optional MOVE) | ; | Parameters SOURCE : REQUIRED. Path to source file or folder. | ; | DESTINATION : REQUIRED. Path to the destination folder. | ; | FLAGS : OPTIONAL. Specifies options for the operation. See remarks for options. | ; | COMMAND : OPTIONAL. Copy = 0 (or undefined); Move = 1 | ; | Remarks 4 - Do not display a progress dialog box. | ; | 8 - Give the file being operated on a new name in a move, copy, or rename | ; | operation if a file with the target name already exists. | ; | 16 - Respond with "Yes to All" for any dialog box that is displayed. | ; | 64 - Preserve undo information, if possible. | ; | 128 - Perform the operation on files only if a wildcard file name (*.*) is specified. | ; | 256 - Display a progress dialog box but do not show the file names. | ; | 512 - Do not confirm the creation of a new directory if the operation requires | ; | one to be created. | ; | 1024 - Do not display a user interface if an error occurs. | ; | 2048 - Version 4.71. Do not copy the security attributes of the file. | ; | 4096 - Only operate in the local directory. Don't operate recursively into subdirectories. | ; | 8192 - Version 5.0. Do not copy connected files as a group. Only copy the specified files. | ; +------------------------------------------------------------------------------------------------------+ Function GUICopy($CopyMode, $sSrc, $sDest, Optional $lFlags, $bMove) Dim $objFldr, $StartTick, $EndTick, $TicksNeeded, $AbortTime $AbortTime = 1500 If Left($sDest,1) = "\" $sDest = SubStr($sDest, 1, Len($sDest)-1) EndIf ; -- Check Source Folder -- If NOT Exist($sSrc) Exit 2 EndIf ; -- Check Destination Folder -- If NOT Exist($sDest) Exit 3 EndIf If $CopyMode = 0 ; -- Use Kix Copy Function -- Copy $sSrc $sDest /R /H /C Exit @ERROR Else ; -- Use GUI Copy Function -- $objFldr = $objShell.NameSpace($sDest) $StartTick = @TICKS If $bMove $objFldr.MoveHere($sSrc, $lFlags) Else $objFldr.CopyHere($sSrc, $lFlags) EndIf $EndTick = @TICKS If @ERROR If @ERROR < 0 Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf Exit @ERROR Else ; -- Get Time Needed to perform the action -- $TicksNeeded = $EndTick - $StartTick ; -- Get FileName -- $FileName = Split($sSrc, "\")[Ubound(Split($sSrc, "\"))] ; -- Check For Cancel -- If NOT Exist("$sDest\$FileName") If $TicksNeeded >= $AbortTime ; -- Return Custom Error for Cancel Button Pressed -- Exit 50001 Else Exit 50000 EndIf EndIf EndIf EndIf EndFunction ; +-[Name]-----------------+ ; | Function SelectFolder | ; +-[Comment]--------------+-----------------------------------------------------------------------------------+ ; | This function opens a Folder browser window | ; +------------------------------------------------------------------------------------------------------------+ ; | AUTHOR : Lonkero | ; | SYNTAX : SelectFolder(TITLE,[,MODE][,ROOT]) | ; | PARAMETERS: TITLE - Title to show in dialog | ; | ROOT - Optional. Specifies the root of the Browse dialog box | ; | The user cannot browse higher in the architecture than this folder. | ; | If this value is not specified, the root of the Browse dialog box is the desktop. | ; | MODE - Optional. Changes the mode to show in dialog: | ; | 2 = Do not include network folders below the domain level in the dialog box's | ; | tree view control. | ; | 16 = Include an edit control in the browse dialog box that allows the user to type | ; | the name of an item. | ; | 4096 = Only return computers. If the user selects anything other than a computer, | ; | the OK button is grayed. | ; | 8192 = Only return printers. If the user selects anything other than a printer, | ; | the OK button is grayed. | ; | 16384 = The browse dialog box will display files as well as folders. | ; | RETURNS : The full path to folder, or error if user pressed cancel. | ; +------------------------------------------------------------------------------------------------------------+ Function SelectFolder($Title, optional $Mode, $Root, $FileName) Dim $Selection $Selection = $objShell.BrowseForFolder(0, $Title, 0 + $Mode, $Root).self.path If Len($Selection) If InStrRev($Selection, "\") = Len($Selection) $Selection = SubStr($Selection, 1, Len($Selection)-1) EndIf If $FileName ; -- Add FileName to Path -- $Selection = "$Selection\$FileName" If NOT Exist($Selection) Exit 2 EndIf EndIf $SelectFolder = $Selection Else Exit 2 EndIf EndFunction ; +-[Name]---------------+ ; | Function FileDialog | ; +-[Comment]------------+----------------------------+ ; | Uses the OpenDialogs to return a selected file or | ; | the SaveDialogs to save a file | ; | Date: 25-08-2006 (StigterA) | ; +---------------------------------------------------+ Function FileDialog($Type, Optional $File, $StartDir, $Filters, $FilterIndex, $Restore) Dim $System, $Form, $Filter ; -- Create Form if one was not supplied -- $System = CreateObject("Kixtart.System") If NOT @ERROR $Form = $System.Form Else ; -- KixForms not available - Exit Function with the error -- Exit @ERROR EndIf $Type = Lcase($Type) Select Case $Type = "save" $Form.Dialog = $System.SaveFileDialog() $Form.Dialog.Filename = IIf($File, $File, "") Case $Type = "open" $Form.Dialog = $System.OpenFileDialog() Case Exit EndSelect If NOT @ERROR ; -- Use StartDir as Initial directory if supplied -- $Form.Dialog.InitialDirectory = IIf($StartDir, $StartDir, @SCRIPTDIR) If NOT $Filters ; -- Use All Files filter if nothing is supplied -- $Form.Dialog.Filter = "All files (*.*)|*.*" Else ; -- Combine Filters -- For Each $Filter In Split($Filters, "|") $Filter = Lcase($Filter) If $Form.Dialog.Filter = "" $Form.Dialog.Filter = $Filter + " files (*." + $Filter + ")|*." + $Filter Else $Form.Dialog.Filter = $Form.Dialog.Filter + "|" + $Filter + " files (*." + $Filter + ")|*." + $Filter EndIf Next ; -- Set default filter -- $Form.Dialog.FilterIndex = IIf($FilterIndex, $FilterIndex, 0) EndIf ; -- Set Remember last folder on(1)/off(0) or defaults to off -- $Form.Dialog.RestoreDirectory = IIf($Restore, $Restore, 0) ; -- Show Dialog -- If $Form.Dialog.ShowDialog() = $System.DialogResult.OK ; -- Return selected file to function -- $FileDialog = $Form.Dialog.Filename Else $FileDialog = "" EndIf Else ; -- Error openeing Dialog - Exit Function with the error -- Exit @ERROR EndIf ; -- Release variables -- $Form = "" $System = "" $Filter = "" EndFunction ; +----------------------+ ; | Function DiskSpace() | ; +----------------------+-----------------------------------------------------------------------------------+ ; | AUTHOR : Jens Meyer (sealeopard@usa.net) | ; | SYNTAX : DISKSPACE([DRIVE, FORMAT]) | ; | PARAMETERS : DRIVE | ; | optional driveletter, directory, or UNC (defaults to system drive) | ; | FORMAT | ; | optional parameter indicating the units to be used when returning the available disk space | ; | 0 = KB (KiloByte, default) | ; | 1 = MB (MegaByte) | ; | 2 = GB (GigaByte) | ; | 3 = TB (TeraByte) | ; | 4 = PB (PetaByte) | ; | 5 = % (percentage total diskspace, does not support UNCs) | ; +----------------------------------------------------------------------------------------------------------+ Function DiskSpace(Optional $Drive, $Format) Dim $objWMIService, $sWQL, $colDrives, $objDrive, $RootDrive, $bs If NOT $Drive $Drive = $SystemDrive Else $bs = 2 If InStr($Drive, "\") = 1 ; -- UNC Path -- $bs = 4 EndIf ; -- Filter Root -- $RootDrive = Split($Drive, "\") If Ubound($RootDrive) >= $bs $Drive = Join($RootDrive, "\", $bs) EndIf EndIf $Format = Val($Format) If $Format < 5 $Format = IIf($Format=1,1024,IIf($Format=2,1024.0*1024,IIf($Format=3,1024.0*1024*1024,IIf($Format=4,1024.0*1024*1024*1024,1)))) $DiskSpace = CDbl(GetDiskSpace($Drive) / $Format) Else $objWMIService = GetObject('winmgmts:{impersonationLevel=impersonate}!\\' + $WSVar + '\root\cimv2') $sWQL = "SELECT Size, FreeSpace FROM Win32_LogicalDisk WHERE Name='" + Left($Drive,2) + "'" $colDrives = $objWMIService.ExecQuery($sWQL) For Each $objDrive in $colDrives $DiskSpace = CDbl($objDrive.FreeSpace / $objDrive.Size) * 100 Next EndIf Exit @ERROR EndFunction ; +--------------------+ ; | Function GetSize() | ; +--------------------+-------------------------------------------------------------------------------------+ ; | SYNTAX : GetSize([File, Format]) | ; | PARAMETERS : FILE : Optional driveletter, directory, or UNC (defaults to system drive) | ; | FORMAT : Optional parameter indicating the units to be used when returning the available | ; | disk space | ; | 0 = KB (KiloByte, default) | ; | 1 = MB (MegaByte) | ; | 2 = GB (GigaByte) | ; | 3 = TB (TeraByte) | ; | 4 = PB (PetaByte) | ; | 5 = % (percentage total diskspace, does not support UNCs) | ; +----------------------------------------------------------------------------------------------------------+ Function GetSize($File, Optional $Format) Dim $FileSize If $Format $Format = Val($Format) $Format = IIf($Format=1,1024,IIf($Format=2,1024.0*1024,IIf($Format=3,1024.0*1024*1024,IIf($Format=4,1024.0*1024*1024*1024,1)))) Else ; -- Default is KB -- $Format = 1024 EndIf ; -- Get File Size -- $FileSize = GetFileSize($File) If $FileSize <= $Format $GetSize = 1 Else $GetSize = CDbl($FileSize / $Format) EndIf EndFunction ; +------------------------+ ; | Function ConvertTime() | ; +------------------------+------------------------------------+ ; | Converts Time-format to Seconds and Seconds to Time-format. | ; +-------------------------------------------------------------+ Function ConvertTime($Option, $Value) Dim $lSeconds, $lMinutes, $lHours, $Units $lSeconds = 0 $lMinutes = 0 $lHours = 0 Select Case $option = 1 ; -- Convert Seconds to HH:MM:SS -- If NOT VarType($Value) = 3 OR ($Value < 0) Exit(1) EndIf Select Case $Value < 60 If $Value < 10 $Value = "0" + $Value EndIf $ConvertTime = "0:00:" + $Value Case $Value < 3600 $lMinutes = $Value/60 $Value = $Value - $lMinutes * 60 If $lMinutes < 10 $lMinutes = "0" + $lMinutes EndIf If $Value < 10 $Value = "0" + $Value EndIf $ConvertTime = "0:" + $lMinutes + ":" + $Value Case 1 $lHours = $Value / 3600 $Value = $Value - $lHours * 3600 $lMinutes = $Value / 60 $Value = $Value - $lMinutes * 60 If $lMinutes < 10 $lMinutes = "0" + $lMinutes EndIf If $Value < 10 $Value = "0" + $Value EndIf $ConvertTime = "" + $lHours + ":" + $lMinutes + ":" + $Value EndSelect Exit(0) Case $Option = 2 ; -- Convert HH:MM:SS to Seconds -- If NOT VarType($Value) = 8 Exit(1) EndIf $Units = Split($Value, ":") If Ubound($Units) = 2 If ($Units[0] >= 0) AND ($Units[0] <= 23) $lSeconds = Val($Units[0]) * 3600 EndIf If ($Units[1] >= 0) AND ($Units[1] <= 59) $lSeconds = $lSeconds + (Val($Units[1]) * 60) EndIf $ConvertTime = $lSeconds + $Units[2] Else Exit(1) EndIf Case 1 EndSelect EndFunction ; +----------------+ ; | Function Dot() | ; +----------------+-------------------------------------------+ ; | Converts a value into a decimal thousand seperated string. | ; +------------------------------------------------------------+ Function Dot($Value) If $Value >= 1000 $Value = FormatNumber($Value, 0, 0, 0, -1) EndIf $Dot = CStr($Value) EndFunction ; +-[Name]------------+ ; | Function Replace | ; +-[Comment]---------+-------------------------+ ; | This function Replaces a string in a string | ; +---------------------------------------------+ Function Replace($String, $SS, $RS) $Replace = Join(Split($String, $SS), $RS) EndFunction ; +----------------------+ ; | Function SyncFiles() | ; +----------------------+--------+ ; | Synchronize files and folders | ; +-------------------------------+ Function SyncFiles($Option, $SyncFrom, $SyncTo, Optional $Count) Dim $File, $FileType, $FileSize, $FileTime, $FileTimeTo, $FileTimeFrom, $FileSizeTo, $FileSizeFrom If ($FormInv.Running = 1) OR ($FormSync.Running = 1) Select ; -- Just CLone Source to Destination -- Case $Option = 1 $File = Dir("$SyncFrom\*.*",1) While ($File <> "") AND (@ERROR = 0) AND (($FormInv.Running = 1) OR ($FormSync.Running = 1)) ; -- Get File Attributes -- $FileType = GetFileAttr("$SyncFrom\$File") & 16 If $FileType = 16 ; -- Folder -- If $CB_Opt_SubFldrs.Checked = 0 If ($File <> ".") AND ($File <> "..") If NOT Exist("$SyncTo\$File") If NOT $Count ShellCmd(2,"$SyncTo\$File", "", "", 1) Else $DirNrAdd = $DirNrAdd + 1 FastSync(1, 2, "$SyncTo\$File") InvForm(2) EndIf EndIf SyncFiles(1,"$SyncFrom\$File","$SyncTo\$File", $Count) EndIf EndIf Else ; -- Get File Size in KB -- $FileSize = GetSize("$SyncFrom\$File") $FileNrChecked = $FileNrChecked + 1 $FileSizeChecked = CDbl($FileSizeChecked + $FileSize) If NOT $Count ShellCmd(4,"$SyncFrom\$File","$SyncTo\$File", $FileSize, 1) Else $FileNrAdd = $FileNrAdd + 1 $FileSizeTot = CDbl($FileSizeTot + $FileSize) FastSync(1, 1, "$SyncFrom\$File", "$SyncTo\$File", $FileSize) InvForm(1) EndIf EndIf ; -- Get Next File -- $File = Dir("",1) Loop ; -- Synchronize Between Source and Destination -- Case $Option = 2 $File = Dir("$SyncFrom\*.*",1) While ($File <> "") AND (@ERROR = 0) AND (($FormInv.Running = 1) OR ($FormSync.Running = 1)) ; -- Get File Attributes -- $FileType = GetFileAttr("$SyncFrom\$File") & 16 If $FileType = 16 ; -- Folder -- If $CB_Opt_SubFldrs.Checked = 0 If ($File <> ".") AND ($File <> "..") If NOT Exist("$SyncTo\$File") If NOT $Count ShellCmd(2,"$SyncTo\$File", "", "", 1) Else $DirNrAdd = $DirNrAdd + 1 FastSync(1, 2, "$SyncTo\$File") InvForm(2) EndIf EndIf SyncFiles(2, "$SyncFrom\$File", "$SyncTo\$File", $Count) EndIf EndIf Else ; -- Get File Size in KB -- $FileSize = GetSize("$SyncFrom\$File") $FileNrChecked = $FileNrChecked + 1 InvForm(1) If NOT Exist("$SyncTo\$File") ; -- Copy file to destination -- $FileSizeChecked = CDbl($FileSizeChecked + $FileSize) If NOT $Count ShellCmd(4, "$SyncFrom\$File", "$SyncTo\$File", $FileSize, 1) Else $FileNrAdd = $FileNrAdd + 1 $FileSizeTot = CDbl($FileSizeTot + $FileSize) FastSync(1, 1, "$SyncFrom\$File", "$SyncTo\$File", $FileSize) InvForm(1) EndIf Else ; -- Check Source against destination files -- $FileTimeFrom = GetFileTime("$SyncFrom\$File") $FileSizeFrom = $FileSize ; -- Get File Size in KB -- $FileSizeTo = GetSize("$SyncTo\$File") $FileTimeTo = GetFileTime("$SyncTo\$File") If $FileTimeFrom <> $FileTimeTo If $FileTimeFrom > $FileTimeTo $FileSizeChecked = CDbl($FileSizeChecked + $FileSizeFrom) If NOT $Count ; -- Copy File from Source to Destination -- ShellCmd(4, "$SyncFrom\$File", "$SyncTo\$File", $FileSizeFrom, 1) Else $FileNrAdd = $FileNrAdd + 1 $FileSizeTot = CDbl($FileSizeTot + $FileSizeFrom) FastSync(1, 1, "$SyncFrom\$File", "$SyncTo\$File", $FileSizeFrom) InvForm(1) EndIf Else $FileSizeChecked = $FileSizeChecked + $FileSizeTo If NOT $Count If $CB_Opt_Source.Checked = 0 ; -- Copy File from Destination to Source -- ShellCmd(4,"$SyncTo\$File","$SyncFrom\$File", $FileSizeTo, 1) Else Progress("No update to source : " + $SyncFrom + "\" + $File + " (Skipped)") EndIf Else If $CB_Opt_Source.Checked = 0 $FileNrAdd = $FileNrAdd + 1 $FileSizeTot = CDbl($FileSizeTot + $FileSizeTo) FastSync(1, 1, "$SyncTo\$File", "$SyncFrom\$File", $FileSizeTo) EndIf InvForm(1) EndIf EndIf Else ; -- Files are the same -- $FileSizeChecked = CDbl($FileSizeChecked + $FileSizeFrom) InvForm(2) If NOT $Count Progress("Same File : " + $SyncFrom + "\" + $File + " (Skipped)") EndIf EndIf EndIf EndIf ; -- Get Next File -- $File = Dir("", 1) Loop EndSelect EndIf EndFunction ; +---------------------+ ; | Function FastSync() | ; +---------------------+----------------------------------------------+ ; | Uses a non-visible listview to create a list of create folders and | ; | copy files actions. | ; +--------------------------------------------------------------------+ Function FastSync($Option, Optional $Action, $Source, $Destination, $FileSize) Dim $Item, $x If $CB_Opt_FastSync.Checked <> 0 Select Case $Option = 1 ; -- Create List -- Select Case $Action = 1 ; -- Insert Copy File Entry -- $Item=$LV_FastSync.Items.Add("copy") $Item.SubItems(1).Text = $Source $Item.SubItems(2).Text = $Destination $Item.SubItems(3).Text = $FileSize Case $Action = 2 ; -- Insert Make Directory Entry -- $Item=$LV_FastSync.Items.Add("md") $Item.SubItems(1).Text = $Source Case 1 EndSelect Case $Option = 2 ; -- Execute List -- $x = 0 While $FormSync.Running = 1 AND ($x < $LV_FastSync.Items.Count) ; -- Start Static Sync -- $Item = $LV_FastSync.Items($x) Select Case $Item.Text = "copy" ; -- Copy File -- $FileNrChecked = $FileNrChecked + 1 $FileSizeChecked = CDbl($FileSizeChecked + $Item.SubItems(3).Text) ShellCmd(4, $Item.SubItems(1).Text, $Item.SubItems(2).Text, $Item.SubItems(3).Text, 1) Case $Item.Text = "md" ; -- Create Folder -- ShellCmd(2, $Item.SubItems(1).Text, "", "", 1) Case 1 EndSelect $x = $x + 1 Loop Case 1 EndSelect EndIf EndFunction ; +---------------------+ ; | Function ShellCmd() | ; +---------------------+------------------------------------+ ; | Executes a command and handles any errors that may occur | ; +----------------------------------------------------------+ Function ShellCmd($Option, $Source, Optional $Destination, $FileSize, $PBar) Dim $Str, $DiskFree, $Err, $SErr $B_Bar_Status.Icon = $System.BuiltinIcons($IGreen) Select Case $Option = 1 ; -- Shell -- $Str = "Shell $CmdInt + $Source" Shell $CmdInt + $Source Case $Option = 2 ; -- Kix MD -- $Str = "MD $Source" MD $Source Case $Option = 3 ; -- Kix Copy -- $Str = "Copy to $Destination [" + Dot($FileSize) + " KB]" Copy $Source $Destination /R /H /C Case $Option = 4 ; -- GUI Copy -- $Str = "Copy to $Destination [" + Dot($FileSize) + " KB]" $Destination = Join(Split($Destination, "\"), "\", Ubound(Split($Destination, "\"))) GUICopy($CopyMode, $Source, $Destination, 15952, 0) Case 1 EndSelect $Err = @ERROR $SErr = @SERROR If $Err Select Case $Option = 2 ; -- Folder creation fail counter -- $DirErr = $DirErr + 1 Case ($Option = 3) OR ($Option = 4) ; -- File Copy fail counter -- $FileErr = $FileErr + 1 Case 1 EndSelect If $Err > 50000 Select Case $Err = 50001 $SErr = "Destination file missing after copy (waiting " + $DelayTime + " ms to enable abort.)" Case 1 EndSelect $B_Bar_Status.Icon = $System.BuiltinIcons($IYellow) Else $SErr = "Destination file missing after copy!" $B_Bar_Status.Icon = $System.BuiltinIcons($IRed) EndIf Progress($Str, $PBar, $Err, $SErr) Else $B_Bar_Status.Icon = $System.BuiltinIcons($IBlack) Select Case $Option = 2 ; -- Increase Folder Creation Counter -- $DirNrAdd = $DirNrAdd + 1 Case ($Option = 3) OR ($Option = 4) $FileNrAdd = $FileNrAdd + 1 $FileSizeTot = CDbl($FileSizeTot + $FileSize) $TB_Info_Current_Fc_Value.Text = Dot($FileNrAdd) $TB_Info_Current_TotalSize_Value.Text = Dot($FileSizeTot) ; -- Update DiskSpace Free -- $DiskFree = DiskSpace($TB_Loc_Destination.Text) $TB_Free_Disk_Value.Text = Dot($DiskFree) Case 1 EndSelect Progress($Str + " (Success)", $PBar) EndIf EndFunction ; +---------------------+ ; | Function Progress() | ; +---------------------+--------------------------------------------+ ; | Shows the progress in the listviews and updates the progress bar | ; +------------------------------------------------------------------+ Function Progress($ProgressText, Optional $PBar, $Err, $SErr) Dim $Item, $Column $=Execute($FormSync.DoEvents(1)) If $ProgressText <> "" If $Err $Item = $LV_Fail.Items.Insert(0,@TIME) $Item.SubItems(1).Text = $Err $Item.SubItems(2).Text = $SErr $Item.SubItems(3).Text = $ProgressText ; -- Adjust Column Size -- For Each $Column In $LV_Fail.Columns $Column.Width = -2 Next Else If $LV_His.Enabled $Item = $LV_His.Items.Insert(0,@TIME) $Item.SubItems(1).Text = $ProgressText ; -- Adjust Column Size -- For Each $Column In $LV_His.Columns $Column.Width = -2 Next EndIf EndIf EndIf If $PB_Bar_Progress.Enabled If ($PBar = 1) AND ($PB_Bar_Progress.Value < $PB_Bar_Progress.Maximum) If $ProgBarInc > 100 $ProgBarValue = $ProgBarValue + 1 If ($ProgBarValue * 10) >= ($ProgBarInc / 10) $PB_Bar_Progress.Value = $PB_Bar_Progress.Value + 1 $ProgBarValue = 0 EndIf Else $PB_Bar_Progress.Value = $PB_Bar_Progress.Value + 1 EndIf EndIf EndIf UpdateTimer() If $Err > 50000 ; -- Enable the user to cancel the script before continuing copying files -- Delay($DelayTime, $FormSync) EndIf EndFunction ; +-[Name]----------+ ; | Function Delay | ; +-[Comment]-------+---------------------------+ ; | Uses the sleep command to delay the script. | ; +---------------------------------------------+ Function Delay($STime, Optional $Form) Dim $Target, $Cntr $Target = @TICKS Do Sleep 0.001 If $Form $=Execute($Form.DoEvents(1)) EndIf Until Val((@TICKS - $Target)) >= Val($STime) EndFunction ; +------------------------+ ; | Function UpdateTimer() | ; +------------------------+-----------------------------+ ; | Shows the time in seconds that the script is running | ; +------------------------------------------------------+ Function UpdateTimer() Dim $CurrentTick If $StartTime $CurrentTick = @TICKS If (NOT $PreviousTick) OR ($CurrentTick - $PreviousTick >= 1000) $TB_Timers_Current_Value.Text = ConvertTime(1, ConvertTime(2, @TIME) - $StartTime) $PreviousTick = @TICKS EndIf EndIf EndFunction ; +---------------------+ ; | Function Stop_Inv() | ; +---------------------+--------------------+ ; | Handles the Stop Inventory Button action | ; +------------------------------------------+ Function Stop_Inv() If $FormInv.MsgBox("Stop Inventory?!" + @CRLF + "This process must be completed to" + @CRLF + "be able to synchronize!", "Request", 68) = 6 $FormInv.Running = 0 $FormSync.Running = 0 $PB_Inventory.Value = $PB_Inventory.Max $TB_Message.Text = 'Inventory Skipped..' Progress($TB_Message.Text) Progress("Aborted by user request!") Sleep 1 $FormInv.Visible = 0 EndIf EndFunction ; +------------------+ ; | Function Start() | ; +------------------+--------------+ ; | Handles the Start Button action | ; +---------------------------------+ Function Start($Source, $Destination) Dim $DiskFree, $StartSec, $StopSec, $WorkSec, $DstChk ; -- Clear -- $ProgBarCount = 1 $LV_His.Items.Clear $LV_Fail.Items.Clear $LV_FastSync.Items.Clear $TB_Timers_Start_Value.Text = "--:--" $TB_Timers_Done_Value.Text = "--:--" $TB_Info_Check_Ftc_Value.Text = "-" $TB_Info_Check_TotalSize_Value.Text = "-" $TB_Info_Current_Fc_Value.Text = "-" $TB_Info_Current_TotalSize_Value.Text = "-" $TB_Free_Disk_Value.Text = "-" If ($Source <> "") AND ($Destination <> "") If (($CB_Opt_Log.Checked <> 0) AND ($LogFile <> "LogFile")) OR ($CB_Opt_Log.Checked = 0) OR (($CB_Opt_Log.Checked <> 0) AND ($LogFile = "LogFile") AND ($AutoMode = 1)) $DstChk = Lcase(SubStr($Destination, 1, Len($Source))) If Lcase($Source) <> $DstChk ; -- Check for logfile name in unattended mode -- If (($CB_Opt_Log.Checked <> 0) AND ($LogFile = "LogFile") AND ($AutoMode = 1)) $LogFile = $TmpDir + "\" + $ScrTitle + "(" + @DATE + "-" + @TIME + ")" EndIf $B_Bar_Status.Icon = $System.BuiltinIcons($IGreen) $B_Con_Stop.Text = "Abort" $TB_Timers_Start_Value.Text = @TIME $StartTime = ConvertTime(2, $TB_Timers_Start_Value.Text) $FormSync.Running = 1 ; -- Init -- $FileNrAdd = 0 $DirNrAdd = 0 $FileNrChecked = 0 $FileNrRem = 0 $DirNrRem = 0 $FileSizeTot = 0 $FileSizeChecked = 0 $FileErr = 0 $DirErr = 0 ; -- Run Inventory -- $PB_Inventory.Value = 0 $PB_Bar_Progress.Value = 0 $TB_Message.Text = "Please wait.. Checking.." If $CB_Opt_AddLast.Checked <> 0 If NOT Exist($Destination) ; -- Create SubFolder -- Progress("AddLast option Enabled : Creating Folder " + $Destination) ShellCmd(2, $Destination) EndIf EndIf If $CB_Opt_NoInventory.Checked = 0 Progress("Starting inventory of folder : " + $Source) $FormInv.ShowModal $FormInv.Running = 1 If $AutoMode = 0 $FormSync.Text = "$ScrTitle $ScrVer (Running Inventory)" Else $FormSync.Text = "$ScrTitle $ScrVer (Running Inventory) (Unattended Mode)" EndIf If $CB_Opt_NoSync.Checked = 0 ; -- Run Sync Inventory -- SyncFiles(2, $Source, $Destination, 1) Else ; -- Run Copy Inventory -- SyncFiles(1, $Source, $Destination, 1) EndIf ; -- Set ProgressBar Maxvalue -- $ProgBarMax = CDbl($FileNrAdd + $DirNrAdd) $PB_Bar_Progress.Max = $ProgBarMax $ProgBarInc = 100 If $ProgBarMax > $PB_Bar_Progress.Maximum $a = $PB_Bar_Progress.Maximum $b = $ProgBarMax $xa = $b / $a $c = $b - ($a*$xa) $xb = ($c*100) / $a $ProgBarInc= Val(($xa*100) + $xb) EndIf If $FormInv.Visible = 1 $PB_Inventory.Value = $PB_Inventory.Maximum $TB_Message.Text = 'Inventory Done..' Sleep 1 $FormInv.Visible = 0 $FormInv.Running = 0 EndIf Else If $AutoMode = 0 $FormSync.Text = "$ScrTitle $ScrVer (No Inventory)" Else $FormSync.Text = "$ScrTitle $ScrVer (No Inventory) (Unattended Mode)" EndIf $PB_Bar_Progress.Maximum = 0 $PB_Bar_Progress.Enabled = 0 EndIf If $FormSync.Running = 1 OR ($CB_Opt_NoInventory.Checked <> 0) If $CB_Opt_NoInventory.Checked = 0 If $AutoMode = 0 $FormSync.Text = "$ScrTitle $ScrVer (Running Synchronization)" Else $FormSync.Text = "$ScrTitle $ScrVer (Running Synchronization) (Unattended Mode)" EndIf ; -- Display Results -- Progress("Files To Copy : " + Dot($FileNrAdd)) Progress("Folders To Create : " + Dot($DirNrAdd)) Progress("Files Checked : " + Dot($FileNrChecked)) Progress("Total FileSize Checked (KB) : " + Dot($FileSizeChecked)) Progress("Total FileSize to be copied (KB) : " + Dot($FileSizeTot)) Progress("Inventory Done...") Else If $AutoMode = 0 $FormSync.Text = "$ScrTitle $ScrVer (Running Copy)" Else $FormSync.Text = "$ScrTitle $ScrVer (Running Copy) (Unattended Mode)" EndIf Progress("No data available for progress information (No Inventory was checked)") EndIf $B_Bar_Status.Icon = $System.BuiltinIcons($IBlack) ; -- Disable Buttons -- $B_Con_Start.Enabled = 0 $B_Loc_Destination.Enabled = 0 $B_Loc_Source.Enabled = 0 $B_Opt_Log.Enabled = 0 ; -- Check if work has to be done -- If ($FileNrAdd > 0) OR ($DirNrAdd > 0) OR ($CB_Opt_NoInventory.Checked <> 0) ; -- Check if more then files are to be copied -- If ($FileNrAdd >= $MaxFiles) AND ($CB_opt_NoLog.Checked = 0) If $AutoMode = 0 If $FormSync.MsgBox("More then " + Dot($MaxFiles) + " files need to be copied and logging is enabled." + @CRLF + "This could greatly impact the performance and memory usage!" + @CRLF + @CRLF + "Do you want to disable logging?", "Disable Logging?", 52) = 6 $CB_opt_NoLog.Checked = -1 EndIf Else $CB_opt_NoLog.Checked = -1 EndIf If $CB_opt_NoLog.Checked <> 0 $CB_Opt_Log.Enabled = 0 $CB_Opt_Log.Checked = 0 $B_Opt_Log.Enabled = 0 $LV_His.Enabled = 0 EndIf EndIf ; -- Disable Some Controls -- $CB_Opt_SubFldrs.Enabled = 0 $CB_Opt_Source.Enabled = 0 $CB_Opt_NoSync.Enabled = 0 $CB_Opt_FastSync.Enabled = 0 $CB_Opt_AddLast.Enabled = 0 $CB_Opt_NoInventory.Enabled = 0 $CB_Opt_NativeCopy.Enabled = 0 $CB_Opt_Log.Enabled = 0 $CB_Opt_NoLog.Enabled = 0 ; -- Check FileSize against available Diskspace -- $DiskFree = DiskSpace($Destination) $TB_Free_Disk_Value.Text = Dot($DiskFree) Progress("Calculating Diskspace...") Progress("Source size (KB) : " + Dot($FileSizeTot)) If @ERROR Progress("Free diskspace on destination could not be determined!", "", @ERROR, @SERROR) Else Progress("Destination free (KB) : " + Dot($DiskFree)) If $DiskFree < $FileSizeTot Progress("Data will not fit on destination!") If $AutoMode = 0 If $FormSync.MsgBox("Destination does not have enough free space!" + @CRLF + "Source Size (KB) : " + Dot($FileSizeTot) + @CRLF + "Free Space (KB) : " + Dot($DiskFree) + @CRLF + @CRLF + "Continue Copy?", "Warning", 52) = 7 $FormSync.Running = 0 EndIf Else ; -- Abort Script in Unattended Mode if NoSpace option is not set -- If $NoSpace = 0 $FormSync.Running = 0 EndIf EndIf EndIf EndIf If $FormSync.Running = 1 ; -- Init -- $FileNrAdd = 0 $DirNrAdd = 0 $FileNrChecked = 0 $FileNrRem = 0 $DirNrRem = 0 $FileSizeTot = 0 $FileSizeChecked = 0 $FileErr = 0 $DirErr = 0 ; -- Sync -- $FormSync.Running = 1 Progress("Starting synchronization") If ($CB_Opt_NoSync.Checked = 0) OR ($CB_Opt_NoInventory.Checked <> 0) If $CB_Opt_FastSync.Checked = 0 Progress("Using normal sync method.") ; -- Sync Files -- SyncFiles(2, $Source, $Destination) Else Progress("Using fast sync method.") ; -- Sync Files using fast Sync -- FastSync(2) EndIf Else Progress("Using copy method.") ; -- Copy Files -- SyncFiles(1, $Source, $Destination) EndIf ; -- Display Results -- Progress("Files Copied : " + Dot($FileNrAdd)) Progress("File Copies Failed : " + Dot($FileErr)) Progress("Folders Created : " + Dot($DirNrAdd)) Progress("Folder Creations Failed : " + Dot($DirErr)) Progress("Files Checked : " + Dot($FileNrChecked)) Progress("Total FileSize Checked (KB) : " + Dot($FileSizeChecked)) Progress("Total FileSize Copied (KB) : " + Dot($FileSizeTot)) $TB_Timers_Done_Value.Text = @TIME $StartSec = ConvertTime(2, $TB_Timers_Start_Value.Text) $StopSec = ConvertTime(2, $TB_Timers_Done_Value.Text) $WorkSec = $StopSec - $StartSec Progress("Time Needed (sec) : " + Dot($WorkSec) + " (" + ConvertTime(1, $WorkSec) + ")") Progress("Average Speed (KB/s) : " + Dot($FileSizeTot / $WorkSec)) Progress("Synchronization Done...") Else Progress("Copy aborted by user request.") Progress("Reason : Not enough free space on destination.") EndIf ; -- Enable Some Controls -- $CB_Opt_SubFldrs.Enabled = 1 If $CB_Opt_NoInventory.Checked = 0 $CB_Opt_Source.Enabled = 1 If $CB_Opt_NoSync.Checked = 0 $CB_Opt_FastSync.Enabled = 1 EndIf If $CB_Opt_FastSync.Checked = 0 $CB_Opt_NoSync.Enabled = 1 EndIf Else $CB_Opt_NoInventory.Enabled = 1 EndIf $CB_Opt_AddLast.Enabled = 1 $CB_Opt_NativeCopy.Enabled = 1 If $CB_opt_NoLog.Checked = 0 $CB_Opt_Log.Enabled = 1 If $CB_Opt_Log.Checked <> 0 $B_Opt_Log.Enabled = 1 EndIf EndIf $CB_Opt_NoLog.Enabled = 1 $PB_Bar_Progress.Enabled = 1 Else ; -- Nothing to synchronize -- $TB_Timers_Done_Value.Text = @TIME Progress("Nothing To Synchronize.") EndIf Else $TB_Timers_Done_Value.Text = @TIME Progress("Copy aborted at user request.") EndIf Else ; -- Source and Destination are the same -- If $AutoMode = 0 $rc = $FormSync.MsgBox("Source and Destination cannot be the same folder (or subfolder)!", "Error", 16) Else Progress("Source (" + $Source + ") and destination (" + $Destination + ") cannot be the same folder (or subfolder)!") EndIf EndIf Else ; -- Logfile Name is not given -- $rc = $FormSync.MsgBox("Please select the logfile." + @CRLF + "If you do not wish to log the progress" + @CRLF + "deselect the 'Log to file' option.", "Warning", 48) EndIf Else ; -- At least One of the entries is empty -- $rc = $FormSync.MsgBox("Source and/or Destination empty!", "Error", 16) EndIf ; -- Log To File -- WriteLogFile($LogFile) ; -- Set Form Not Running -- $FormSync.Text = "$ScrTitle $ScrVer" $FormSync.Running = 0 ; -- Enable Buttons -- $B_Bar_Status.Icon = $System.BuiltinIcons($IBlack) $B_Con_Stop.Text = "Exit" $B_Con_Start.Enabled = 1 $B_Loc_Destination.Enabled = 1 $B_Loc_Source.Enabled = 1 If $ChB_Opt_Log.Checked <> 0 $B_Opt_Log.Enabled = 1 EndIf EndFunction ; +-----------------+ ; | Function Stop() | ; +-----------------+--------------+ ; | Handles the Stop Button action | ; +--------------------------------+ Function Stop() If $FormSync.Running = 1 If $FormSync.MsgBox("Abort Current Operation?!" + @CRLF + "Abort might not be immediate", "Abort script (paused)", 68) = 6 Progress("Aborting synchronization by user request!") ; -- Stop operation -- $FormSync.Running = 0 EndIf Else If $FormSync.MsgBox("Quit Script?!", "Request", 68) = 6 ; -- Exit Program -- $FormSync.Visible = 0 EndIf EndIf EndFunction ;****************************************************************************** ;==[ Logging Functions ]======================================================= ;****************************************************************************** ; +-------------------------+ ; | Function WriteLogFile() | ; +-------------------------+--------------------------------------+ ; | Writes the logfile using the starttime as part of the filename | ; +----------------------------------------------------------------+ Function WriteLogFile($Name) If $CB_Opt_Log.Checked <> 0 If ($Name = "") OR ($Name = "Logfile Name") $Name = $TmpDir + "\" + Join(Split(@TIME, ":"), ".") + ".log" EndIf LV2File("Logging History", $LV_His, $Name, 1) LV2File("Logging Errors", $LV_Fail, $Name) EndIf EndFunction ; +--------------------+ ; | Function LV2File() | ; +--------------------+-------+ ; | Writes a listview to file. | ; +----------------------------+ Function LV2File($Message, $ListView, $File, Optional $NewFile) Dim $Item, $x, $y, $Lines, $Msg $rc = 0 $TB_Log_Message.Text = $Message $PrB_Log.Value = 0 $PrB_Log.Max = $ListView.Items.Count $FormLog.ShowModal If $ListView.Items.Count > 0 If $NewFile = 1 ; -- Del Existing File -- If Exist($File) Del $File /c/f/h Progress("Delete previous logfile : " + $File, "", @ERROR, @SERROR) EndIf Progress("Writing " + $ListView.Items.Count + " lines to Logfile : " + $File) ; -- Create New File & Open for writing -- $rc = Open(1, $File, 5) Else Progress("Adding " + $ListView.Items.Count + " lines to Logfile : " + $File) ; -- Open Existing File for writing -- $rc = Open(1, $File, 4) EndIf If $rc = 0 If NOT $NewFile $=WriteLine(1, @CRLF + "**********************************[ Logging Continued ]***********************************" + @CRLF) EndIf $=WriteLine(1, "---===[ " + $Message + " ]===---") $x = $ListView.Items.Count While $x >= 0 $Item = $ListView.Items($x) $Msg = "" For $y = 0 To $ListView.Columns.Count - 1 $Msg = $Msg + $Item.SubItems($y).Text + Chr(9) Next $Msg = $Msg + $Item.SubItems($ListView.Columns.Count).Text ; -- Write Message To File -- $ = WriteLine(1, $Msg + @CRLF) $PrB_Log.Value = $PrB_Log.Value + 1 $x = $x - 1 Loop ; -- Close File -- $ = Close(1) Progress("Log to file completed...") Else Progress("Logfile " + $File + " creation Failed!", "", @ERROR, @SERROR) EndIf Else Progress("Not data to write to file : " + $File) EndIf $FormLog.Visible = 0 EndFunction ;****************************************************************************** ;==[ Forms ]=================================================================== ;****************************************************************************** ; +-[Name]--------------+ ; | Function Form_Init | ; +-[Comment]-----------+----------------------------------+ ; | Initialize the form & implement KixForms.DLL if needed | ; +--------------------------------------------------------+ Function Form_Init() Dim $Choice, $KixForms_File, $CopyFile $System = CreateObject("Kixtart.System") ; -- Check If KixForms.DLL is implemented -- If NOT $System $CopyFile = 0 ; -- Show Message & Exit script if failure or abort -- If MessageBox("The script was unable to locate the required file KixForms.dll" + @CRLF + "Do you want to try and locate the file yourself?", "Find required file?", 52) = 6 $KixForms_File = SelectFolder("Seacrh for location of the file KIXFORMS.DLL", 2, "", "KixForms.dll") If $KixForms_File $CopyFile = 1 EndIf If $CopyFile = 1 AND $KixForms_File ; -- Try to copy and register file -- Copy $KixForms_File "$SysDir" /c /r /h If NOT @ERROR Shell "REGSVR32.EXE /S $SysDir\KixForms.Dll" If NOT @ERROR Form_Init() Else ; -- Exit program -- $=MessageBox("Script Halted" + $ScrKixForms, "Error occured Installing KixForms.dll", 16) Quit EndIf EndIf Else ; -- Exit program -- $=MessageBox("Script Halted" + $ScrKixForms, "Kixforms Installation Cancelled", 16) Quit EndIf Else ; -- Exit program -- $=MessageBox("Script Halted" + $ScrKixForms, "Kixforms Installation Cancelled", 16) Quit EndIf EndIf EndFunction ; +-[Name]-----------------+ ; | Function WriteLogForm | ; +-[Comment]--------------+---------+ ; | Initialize the WriteLogFile form | ; +----------------------------------+ Function WriteLogForm() ;************* Form ************** $FormLog = $System.Form() $FormLog.FontSize = 8,25 $FormLog.FormBorderStyle = 2 $FormLog.Height = 105 $FormLog.Width = 240 $FormLog.ControlBox = 0 $FormLog.Text = "Writing Logfile" $FormLog.Icon = $System.BuiltinIcons(3) $FormLog.Center ;************* TB_Message ************** $TB_Log_Message = $FormLog.Controls.TextBox("", 10, 10, 210, 20) $TB_Log_Message.BorderStyle = 1 $TB_Log_Message.FontSize = 8,25 $TB_Log_Message.ReadOnly = 1 $TB_Log_Message.TextAlign = 2 ;************* TB_Inventory ************** $PrB_Log = $FormLog.Controls.ProgressBar("", 10, 40, 210, 19) $PrB_Log.Style = 1 $PrB_Log.Value = 0 $PrB_Log.Max = 100 ;************************************** EndFunction ; +-[Name]------------+ ; | Function InvForm | ; +-[Comment]---------+--------------------------------------+ ; | Initialize the Inventory form & update the progress bar. | ; +----------------------------------------------------------+ Function InvForm(Optional $Option) Dim $B_Inv_Stop If NOT $Option $Option = 0 EndIf Select Case $Option = 0 ;************* FormInv ************** $FormInv = $System.Form() $FormInv.FontSize = 8,25 $FormInv.FormBorderStyle = 2 $FormInv.Height = 165 $FormInv.Width = 240 $FormInv.ControlBox = 0 $FormInv.Text = "Inventory" $FormInv.Icon = $System.BuiltinIcons(43) $FormInv.Center ;************* TB_Message ************** $TB_Message = $FormInv.Controls.TextBox("", 10, 10, 210, 19) $TB_Message.BorderStyle = 1 $TB_Message.FontSize = 8,25 $TB_Message.ReadOnly = 1 $TB_Message.TextAlign = 2 ;************* TB_Files_Tot ************** $TB_Files_Tot = $FormInv.Controls.TextBox("Files Checked", 10, 40, 110, 19) $TB_Files_Tot.BorderStyle = 1 $TB_Files_Tot.FontSize = 8,25 $TB_Files_Tot.ReadOnly = 1 $TB_Files_Tot.TextAlign = 2 ;************* TB_Files_Tot_Value ************** $TB_Files_Tot_Value = $FormInv.Controls.TextBox("", 130, 40, 90, 20) $TB_Files_Tot_Value.BorderStyle = 2 $TB_Files_Tot_Value.FontSize = 8,25 $TB_Files_Tot_Value.ReadOnly = 1 $TB_Files_Tot_Value.TextAlign = 2 ;************* PB_Inventory ************** $PB_Inventory = $FormInv.Controls.ProgressBar("", 10, 70, 210, 19) $PB_Inventory.Style = 1 $PB_Inventory.Value = 0 $PB_Inventory.Maximum = 100 ;************* B_Inv_Stop ************** $B_Inv_Stop = $FormInv.Controls.Button("Stop", 80, 100, 80, 23) $B_Inv_Stop.FontBold = 1 $B_Inv_Stop.FontSize = 8,25 $B_Inv_Stop.BorderStyle = 2 $B_Inv_Stop.OnClick = "Stop_Inv()" ;************************************** Case $Option = 1 If $FormInv.Running = 1 $=Execute($FormInv.DoEvents(1)) $TB_Info_Check_Ftc_Value.Text = Dot($FileNrAdd) $TB_Info_Check_TotalSize_Value.Text = Dot($FileSizeTot) $TB_Files_Tot_Value.Text = Dot($FileNrChecked) If $PB_Inventory.Value < $PB_Inventory.Maximum $PB_Inventory.Value = $PB_Inventory.Value + 1 Else $PB_Inventory.Value = 0 EndIf UpdateTimer() EndIf Case $Option = 2 If $FormInv.Running = 1 $=Execute($FormInv.DoEvents(1)) If $PB_Inventory.Value < $PB_Inventory.Maximum $PB_Inventory.Value = $PB_Inventory.Value + 1 Else $PB_Inventory.Value = 0 EndIf UpdateTimer() EndIf Case 1 EndSelect EndFunction ; +-[Name]-------------+ ; | Function SyncForm | ; +-[Comment]----------+------------+ ; | Initialize the Main Script form | ; +---------------------------------+ Function SyncForm() Dim $L_Loc, $L_Opt, $L_Con, $L_Timers, $L_Info_Check, $L_Info_Current, $L_Free_Disk, $L_Bar, $L_His ;************* Form ************** $FormSync = $System.Form() $FormSync.FontSize = 8,25 $FormSync.FormBorderStyle = 2 $FormSync.Height = 775 $FormSync.Width = 550 $FormSync.Text = "$ScrTitle $ScrVer" $FormSync.MinimizeBox = 0 $FormSync.MaximizeBox = 0 $FormSync.Icon = $System.BuiltinIcons(61) $FormSync.Running = 0 $FormSync.Center ;************* PB_Sync ************** $B_About = $FormSync.Controls.Button("", 20, 30, 50, 50) $B_About.TabStop = 0 $B_About.BorderStyle = 5 $B_About.Picture = "$SysDir\shell32.dll;24" $B_About.OnClick = "$$=$$FormSync.MsgBox($$About_Message,'About this script',64)" ;************* L_Loc ************** $L_About = $FormSync.Controls.Label("About", 10, 10, 70, 80) $L_About.BorderStyle = 2 $L_About.FontSize = 8,25 ;************************************** ;************* B_Loc_Source ************** $B_Loc_Source = $FormSync.Controls.Button("Source", 100, 30, 90, 23) $B_Loc_Source.FontBold = 1 $B_Loc_Source.FontSize = 8,25 $B_Loc_Source.BorderStyle = 2 $B_Loc_Source.OnClick = "$$TB_Loc_Source.Text = SelectFolder('Select the Source folder', 2) If $$TB_Loc_Source.Text <> '' AND $$TB_Loc_Destination.Text <> '' $$CB_Opt_AddLast.Enabled = 1 Else $$CB_Opt_AddLast.Enabled = 0 EndIf" $B_Loc_Source.ToolTipText = "Open a browse folder window to select a source folder." ;************* TB_Loc_From ************** $TB_Loc_Source = $FormSync.Controls.TextBox("", 200, 30, 230, 20) $TB_Loc_Source.FontSize = 8,25 $TB_Loc_Source.ReadOnly = 1 $TB_Loc_Source.TextAlign = 0 $TB_Loc_Source.TabStop = 0 ;************* B_Loc_Destination ************** $B_Loc_Destination = $FormSync.Controls.Button("Destination", 100, 60, 90, 23) $B_Loc_Destination.FontBold = 1 $B_Loc_Destination.FontSize = 8,25 $B_Loc_Destination.BorderStyle = 2 $B_Loc_Destination.OnClick = "$$TB_Loc_Destination.Text = SelectFolder('Select the Destination folder', 2) If $$TB_Loc_Source.Text <> '' AND $$TB_Loc_Destination.Text <> '' $$CB_Opt_AddLast.Enabled = 1 $$B_Con_Start.Enabled = 1 Else $$CB_Opt_AddLast.Enabled = 0 $$B_Con_Start.Enabled = 0 EndIf" $B_Loc_Destination.ToolTipText = "Open a browse folder window to select a destination folder." ;************* TB_Loc_Destination ************** $TB_Loc_Destination = $FormSync.Controls.TextBox("", 200, 60, 230, 20) $TB_Loc_Destination.FontSize = 8,25 $TB_Loc_Destination.ReadOnly = 1 $TB_Loc_Destination.TextAlign = 0 $TB_Loc_Destination.TabStop = 0 ;************* L_Loc ************** $L_Loc = $FormSync.Controls.Label("Location", 90, 10, 350, 80) $L_Loc.BorderStyle = 2 $L_Loc.FontSize = 8,25 ;************************************** ;************* CB_Opt_SubFldrs ************** $CB_Opt_SubFldrs = $FormSync.Controls.CheckBox("No SubFolders", 20, 120, 120, 24) $CB_Opt_SubFldrs.CheckAlign = 16 $CB_Opt_SubFldrs.FontSize = 8,25 $CB_Opt_SubFldrs.Checked = 0 $CB_Opt_SubFldrs.ToolTipText = "Enable this option if only the root folder is to be" + @CRLF + "synchronized. Subfolders will not be handled." ;************* CB_Opt_Source ************** $CB_Opt_Source = $FormSync.Controls.CheckBox("Destination Only", 140, 120, 120, 24) $CB_Opt_Source.CheckAlign = 16 $CB_Opt_Source.FontSize = 8,25 $CB_Opt_Source.Checked = 0 $CB_Opt_Source.ToolTipText = "Enable this option if the synchronization process" + @CRLF + "may not make changes to the source." ;************* CB_Opt_NoSync ************** $CB_Opt_NoSync = $FormSync.Controls.CheckBox("No Synchronization", 20, 150, 120, 24) $CB_Opt_NoSync.CheckAlign = 16 $CB_Opt_NoSync.FontSize = 8,25 $CB_Opt_NoSync.Checked = 0 $CB_Opt_NoSync.OnClick = "If $$CB_Opt_NoSync.Checked = 0 $$CB_Opt_FastSync.Enabled = 1 $$CB_Opt_NoInventory.Enabled = 1 Else $$CB_Opt_FastSync.Enabled = 0 $$CB_Opt_NoInventory.Enabled = 0 EndIf" $CB_Opt_NoSync.ToolTipText = "Enable this option if the destination" + @CRLF + "does not contain any data." + @CRLF + "This will be just a copy action." ;************* CB_Opt_FastSync ************** $CB_Opt_FastSync = $FormSync.Controls.CheckBox("Use FastSync", 140, 150, 120, 24) $CB_Opt_FastSync.CheckAlign = 16 $CB_Opt_FastSync.FontSize = 8,25 $CB_Opt_FastSync.Checked = 0 $CB_Opt_FastSync.OnClick = "If $$CB_Opt_FastSync.Checked = 0 $$CB_Opt_NoSync.Enabled = 1 $$CB_Opt_NoInventory.Enabled = 1 Else $$CB_Opt_NoSync.Enabled = 0 $$CB_Opt_NoInventory.Enabled = 0 EndIf" $CB_Opt_FastSync.ToolTipText = "Check to Enable FastSync." + @CRLF + "Changes made to either the source or destination after" + @CRLF + "the inventory has run, will be lost." + @CRLF + "Use this if both the source and destination is static." ;************* CB_Opt_AddLast ************** $CB_Opt_AddLast = $FormSync.Controls.CheckBox("Add Last Folder", 260, 120, 100, 24) $CB_Opt_AddLast.CheckAlign = 16 $CB_Opt_AddLast.FontSize = 8,25 $CB_Opt_AddLast.Checked = 0 $CB_Opt_AddLast.Enabled = 0 $CB_Opt_AddLast.OnClick = "AddLastFldr()" $CB_Opt_AddLast.ToolTipText = "Enable this option if the last folder from the source" + @CRLF + "must be created under the destination folder." ;************* CB_Opt_NoInventory ************** $CB_Opt_NoInventory = $FormSync.Controls.CheckBox("No Inventory", 260, 150, 100, 24) $CB_Opt_NoInventory.CheckAlign = 16 $CB_Opt_NoInventory.FontSize = 8,25 $CB_Opt_NoInventory.Checked = 0 $CB_Opt_NoInventory.OnClick = "If $$CB_Opt_NoInventory.Checked = 0 $$CB_Opt_NoSync.Enabled = 1 $$CB_Opt_FastSync.Enabled = 1 $$CB_Opt_Source.Enabled = 1 Else $$CB_Opt_NoSync.Enabled = 0 $$CB_Opt_FastSync.Enabled = 0 $$CB_Opt_Source.Enabled = 0 EndIf $$CB_Opt_Source.Checked = 0" $CB_Opt_NoInventory.ToolTipText = "Check to disable the inventory." + @CRLF + "This mode disables any synchronisation selection and" + @CRLF + "will just copy the source to the destination. (Copy mode)" + @CRLF + "Normal copy without progress information." ;************* CB_Opt_NativeCopy ************** $CB_Opt_NativeCopy = $FormSync.Controls.CheckBox("Use Native Copy", 20, 180, 100, 24) $CB_Opt_NativeCopy.CheckAlign = 16 $CB_Opt_NativeCopy.FontSize = 8,25 $CB_Opt_NativeCopy.Checked = 0 $CB_Opt_NativeCopy.OnClick = "If $$CB_Opt_NativeCopy.Checked <> 0 $$CopyMode = 0 Else $$CopyMode = 1 EndIf" $CB_Opt_NativeCopy.ToolTipText = "Use the integrated copy function instead of" + @CRLF + "the windows native copy mode." + @CRLF + "This mode is faster when copying many small files." + @CRLF + "P.S. Please note that with the copying of" + @CRLF + "large files the script may appear frozen!" ;************* CB_Opt_NoLog ************** $CB_Opt_NoLog = $FormSync.Controls.CheckBox("Disable Logging", 140, 180, 100, 24) $CB_Opt_NoLog.CheckAlign = 16 $CB_Opt_NoLog.FontSize = 8,25 $CB_Opt_NoLog.Checked = 0 $CB_Opt_NoLog.OnClick = "If $$CB_Opt_NoLog.Checked <> 0 $$CB_Opt_Log.Enabled = 0 $$CB_Opt_Log.Checked = 0 $$B_Opt_Log.Enabled = 0 $$LV_His.Enabled = 0 Else $$CB_Opt_Log.Enabled = 1 $$LV_His.Enabled = 1 EndIf" $CB_Opt_NoLog.ToolTipText = "Disable all logging." + @CRLF + "This will disable History logging to screen and" + @CRLF + "disable the logging to file!" + @CRLF + "This can be used to conserve memory when copying" + @CRLF + "large amount of files (> $MaxFiles)." ;************* CB_Opt_Log ************** $CB_Opt_Log = $FormSync.Controls.CheckBox("", 260, 180, 20, 24) $CB_Opt_Log.CheckAlign = 16 $CB_Opt_Log.FontSize = 8,25 $CB_Opt_Log.Checked = 0 $CB_Opt_Log.OnClick = "If $$CB_Opt_Log.Checked <> 0 $$B_Opt_Log.Enabled = 1 Else $$B_Opt_Log.Enabled = 0 EndIf" $CB_Opt_Log.ToolTipText = "Enable this option if the progress must be" + @CRLF + "written to file." ;************* B_Opt_Log ************** $B_Opt_Log = $FormSync.Controls.Button("Logfile", 280, 180, 90, 23) $B_Opt_Log.FontSize = 7 $B_Opt_Log.FontBold = 0 $B_Opt_Log.Enabled = 0 $B_Opt_Log.BorderStyle = 2 $B_Opt_Log.TextAlign = 32 $B_Opt_Log.OnClick = "$$LogFile = FileDialog('save',,,'log',1,1) If $$LogFile <> '' $$B_Opt_Log.Text = Split($$LogFile, '\')[Ubound(Split($$LogFile, '\'))] $$B_Opt_Log.ToolTipText = 'Logfile selected : $$LogFile' Else $$B_Opt_Log.Text = 'Logfile' $$B_Opt_Log.ToolTipText = 'Logfile has not been selected yet.' EndIf" $B_Opt_Log.ToolTipText = "Logfile has not been selected yet." ;************* L_Opt ************** $L_Opt = $FormSync.Controls.Label("Options", 10, 100, 370, 110) $L_Opt.BorderStyle = 2 $L_Opt.FontSize = 8,25 ;************************************** ;************* B_Start ************** $B_Con_Start = $FormSync.Controls.Button("Start", 460, 30, 60, 23) $B_Con_Start.FontBold = 1 $B_Con_Start.FontSize = 8,25 $B_Con_Start.BorderStyle = 2 $B_Con_Start.Enabled = 0 $B_Con_Start.OnClick = "Start($$TB_Loc_Source.Text, $$TB_Loc_Destination.Text)" $B_Con_Start.ToolTipText = "Start Inventory / Synchronization" ;************* B_Stop ************** $B_Con_Stop = $FormSync.Controls.Button("Exit", 460, 60, 60, 23) $B_Con_Stop.FontBold = 1 $B_Con_Stop.FontSize = 8.25 $B_Con_Stop.BorderStyle = 2 $B_Con_Stop.OnClick = "Stop()" $B_Con_Stop.ToolTipText = "Stop/Exit the Script" ;************* L_Loc ************** $L_Con = $FormSync.Controls.Label("Controls", 450, 10, 80, 80) $L_Con.BorderStyle = 2 $L_Con.FontSize = 8,25 ;************************************** ;************* TB_Timers_Start ************** $TB_Timers_Start = $FormSync.Controls.TextBox("Start", 400, 120, 50, 20) $TB_Timers_Start.BorderStyle = 2 $TB_Timers_Start.ReadOnly = 1 $TB_Timers_Start.TextAlign = 2 $TB_Timers_Start.TabStop = 0 ;************* TB_Timers_Start_Value ************** $TB_Timers_Start_Value = $FormSync.Controls.TextBox("", 460, 120, 60, 20) $TB_Timers_Start_Value.BorderStyle = 2 $TB_Timers_Start_Value.ReadOnly = 1 $TB_Timers_Start_Value.TextAlign = 2 $TB_Timers_Start_Value.Text = "--:--" $TB_Timers_Start_Value.TabStop = 0 ;************* TB_Timers_Current ************** $TB_Timers_Current = $FormSync.Controls.TextBox("Current", 400, 150, 50, 20) $TB_Timers_Current.BorderStyle = 2 $TB_Timers_Current.ReadOnly = 1 $TB_Timers_Current.TextAlign = 2 $TB_Timers_Current.TabStop = 0 ;************* TB_Timers_Current_Value ************** $TB_Timers_Current_Value = $FormSync.Controls.TextBox("", 460, 150, 60, 20) $TB_Timers_Current_Value.BorderStyle = 2 $TB_Timers_Current_Value.ReadOnly = 1 $TB_Timers_Current_Value.TextAlign = 2 $TB_Timers_Current_Value.Text = "--:--" $TB_Timers_Current_Value.TabStop = 0 ;************* TB_Timers_Done ************** $TB_Timers_Done = $FormSync.Controls.TextBox("Done", 400, 180, 50, 20) $TB_Timers_Done.BorderStyle = 2 $TB_Timers_Done.ReadOnly = 1 $TB_Timers_Done.TextAlign = 2 $TB_Timers_Done.TabStop = 0 ;************* TB_Timers_Done_Value ************** $TB_Timers_Done_Value = $FormSync.Controls.TextBox("", 460, 180, 60, 20) $TB_Timers_Done_Value.BorderStyle = 2 $TB_Timers_Done_Value.ReadOnly = 1 $TB_Timers_Done_Value.TextAlign = 2 $TB_Timers_Done_Value.Text = "--:--" $TB_Timers_Done_Value.TabStop = 0 ;************* L_Timers ************** $L_Timers = $FormSync.Controls.Label("Timers", 390, 100, 140, 110) $L_Timers.BorderStyle = 2 ;************************************** ;************* TB_FilesToCopy ************** $TB_Info_Check_Ftc = $FormSync.Controls.TextBox("Files To Copy", 20, 240, 80, 19) $TB_Info_Check_Ftc.BorderStyle = 1 $TB_Info_Check_Ftc.FontSize = 8,25 $TB_Info_Check_Ftc.ReadOnly = 1 $TB_Info_Check_Ftc.TextAlign = 2 $TB_Info_Check_Ftc.TabStop = 0 ;************* TB_FilesToCopy_Value ************** $TB_Info_Check_Ftc_Value = $FormSync.Controls.TextBox("", 110, 240, 90, 20) $TB_Info_Check_Ftc_Value.FontSize = 8,25 $TB_Info_Check_Ftc_Value.ReadOnly = 1 $TB_Info_Check_Ftc_Value.TextAlign = 2 $TB_Info_Check_Ftc_Value.Text = "-" $TB_Info_Check_Ftc_Value.TabStop = 0 ;************* TB_TotalSize ************** $TB_Info_Check_TotalSize = $FormSync.Controls.TextBox("Total Size (KB)", 20, 270, 80, 19) $TB_Info_Check_TotalSize.BorderStyle = 1 $TB_Info_Check_TotalSize.FontSize = 8,25 $TB_Info_Check_TotalSize.TextAlign = 2 $TB_Info_Check_TotalSize.TabStop = 0 ;************* TB_TotalSize_Value ************** $TB_Info_Check_TotalSize_Value = $FormSync.Controls.TextBox("", 110, 270, 90, 20) $TB_Info_Check_TotalSize_Value.FontSize = 8,25 $TB_Info_Check_TotalSize_Value.ReadOnly = 1 $TB_Info_Check_TotalSize_Value.TextAlign = 2 $TB_Info_Check_TotalSize_Value.Text = "-" $TB_Info_Check_TotalSize_Value.TabStop = 0 ;************* L_Info_Check ************** $L_Info_Check = $FormSync.Controls.Label("Inventory Info", 10, 220, 200, 80) $L_Info_Check.BorderStyle = 2 ;************************************** ;************* TB_Info_Current_Fc ************** $TB_Info_Current_Fc = $FormSync.Controls.TextBox("Files Copied", 230, 240, 80, 19) $TB_Info_Current_Fc.BorderStyle = 1 $TB_Info_Current_Fc.FontSize = 8,25 $TB_Info_Current_Fc.ReadOnly = 1 $TB_Info_Current_Fc.TextAlign = 2 $TB_Info_Current_Fc.TabStop = 0 ;************* TB_Info_Current_Fc_Value ************** $TB_Info_Current_Fc_Value = $FormSync.Controls.TextBox("", 320, 240, 90, 20) $TB_Info_Current_Fc_Value.FontSize = 8,25 $TB_Info_Current_Fc_Value.ReadOnly = 1 $TB_Info_Current_Fc_Value.TextAlign = 2 $TB_Info_Current_Fc_Value.Text = "-" $TB_Info_Current_Fc_Value.TabStop = 0 ;************* TB_Info_Current_TotalSize ************** $TB_Info_Current_TotalSize = $FormSync.Controls.TextBox("Total Size (KB)", 230, 270, 80, 19) $TB_Info_Current_TotalSize.BorderStyle = 1 $TB_Info_Current_TotalSize.FontSize = 8,25 $TB_Info_Current_TotalSize.TextAlign = 2 $TB_Info_Current_TotalSize.TabStop = 0 ;************* TB_Info_Current_TotalSize_Value ************** $TB_Info_Current_TotalSize_Value = $FormSync.Controls.TextBox("", 320, 270, 90, 20) $TB_Info_Current_TotalSize_Value.FontSize = 8,25 $TB_Info_Current_TotalSize_Value.ReadOnly = 1 $TB_Info_Current_TotalSize_Value.TextAlign = 2 $TB_Info_Current_TotalSize_Value.Text = "-" $TB_Info_Current_TotalSize_Value.TabStop = 0 ;************* L_Info_Current ************** $L_Info_Current = $FormSync.Controls.Label("Progress Info", 220, 220, 200, 80) $L_Info_Current.BorderStyle = 2 ;************************************** ;************* TB_Free_Disk ************** $TB_Free_Disk = $FormSync.Controls.TextBox("Disk Free (KB)", 440, 240, 80, 19) $TB_Free_Disk.FontSize = 8,25 $TB_Free_Disk.ReadOnly = 1 $TB_Free_Disk.TextAlign = 2 $TB_Free_Disk.BorderStyle = 1 $TB_Free_Disk.TabStop = 0 ;************* PB_Free_DiskSpace ************** $TB_Free_Disk_Value = $FormSync.Controls.TextBox("", 440, 270, 80, 20) $TB_Free_Disk_Value.FontSize = 8,25 $TB_Free_Disk_Value.TextAlign = 2 $TB_Free_Disk_Value.ReadOnly = 1 $TB_Free_Disk_Value.Text = "-" $TB_Free_Disk_Value.TabStop = 0 ;************* L_Bar ************** $L_Free_Disk = $FormSync.Controls.Label("Free Space", 430, 220, 100, 80) $L_Free_Disk.BorderStyle = 2 ;************************************** ;************* PB_Bar_Progress ************** $PB_Bar_Progress = $FormSync.Controls.ProgressBar("", 20, 330, 470, 19) $PB_Bar_Progress.Style = 1 $PB_Bar_Progress.Value = 0 $PB_Bar_Progress.Maximum = 1000000 ;************* B_Bar_Status ************** $B_Bar_Status = $FormSync.Controls.Button("", 500, 330, 20, 20) $B_Bar_Status.Icon = $System.BuiltinIcons($IBlack) $B_Bar_Status.BorderStyle = 0 ;************* L_Bar ************** $L_Bar = $FormSync.Controls.Label("Progress", 10, 310, 520, 50) $L_Bar.BorderStyle = 2 ;************************************** ;************* LV_His ************** $LV_His = $FormSync.Controls.ListView("", 20, 390, 500, 180) $LV_His.FontSize = 8,25 $LV_His.GridLines = 1 $LV_His.Header = 1 $LV_His.TabStop = 0 $rc = $LV_His.Columns.Add("Time",60) $rc = $LV_His.Columns.Add("Message",410) ;************* LV_Fail ************** $LV_Fail = $FormSync.Controls.ListView("", 20, 580, 500, 140) $LV_Fail.FontSize = 8,25 $LV_Fail.GridLines = 1 $LV_Fail.Header = 1 $LV_Fail.TabStop = 0 $rc = $LV_Fail.Columns.Add("Time",60) $rc = $LV_Fail.Columns.Add("Code",50) $rc = $LV_Fail.Columns.Add("Failure",180) $rc = $LV_Fail.Columns.Add("Action",180) ;************* LV_FastSync ************** $LV_FastSync = $FormSync.Controls.ListView("", -1, -1, -1, -1) $LV_FastSync.FontSize = 8,25 $LV_FastSync.TabStop = 0 $rc = $LV_FastSync.Columns.Add("",-1) $rc = $LV_FastSync.Columns.Add("",-1) $rc = $LV_FastSync.Columns.Add("",-1) $rc = $LV_FastSync.Columns.Add("",-1) ;************* L_His ************** $L_His = $FormSync.Controls.Label("History", 10, 370, 520, 360) $L_His.BorderStyle = 2 $L_His.FontSize = 8,25 ;************************************** EndFunction