Jump to content

Stuck in BackupPC script


Recommended Posts

Yaah... got it banners, thanks. This was added in my mind already and run the program to a default back up path (with enough space) then run with parameters (of course hide the GUI not visible to user).

Also, had it in mind that a batch file will run to call the program in server when user log-in to their PC (but still not visible to user). How is that?^_^

 

KS15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

Yep that sounds fine. If you were going to write a cmd script you may as well make that copy the files\folders using xcopy or robocopy. No need to mes about with the GUI issues then.

The script I posted is a simple one to show the OP it could be done. It needs finishing to check for copy errors, to handle exceptions and such that may happen, for example if an array isn't created but is called.

There are plenty of free file\folder sync programs that could do a better job and some may accept cmd line parameters, no point reinventing the wheel. :)

Link to comment
Share on other sites

# ;NoTrayIcon
;MsgBox($MB_SYSTEMMODAL, "Title", $test)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Backup.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3> ; #### ADDED ####
#include <GuiEdit.au3>
#include <Array.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
;#include <IniToArray.au3>

Global $sInfo
Global $Destination
Global $Includebackup
Global $Flashballoon = True
Local  $timer = TimerInit()
Global $Currfile
Global $Arrfile
Global $INIFilePath = @ScriptDir & "\CurrentDir.ini"


#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Backup", 628, 385, 441, 124)
$Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Input1 = GUICtrlCreateInput("", 184, 11, 353, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Edit1 = GUICtrlCreateEdit("", 4, 160, 613, 185)
GUICtrlSetData(-1, "---> AON Backup Tool v1")
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
$BACKUP = GUICtrlCreateButton("Backup", 454, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Exit = GUICtrlCreateButton("Exit", 536, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 16, 356, 157, 17)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetTip(-1, "Use to compress data")
$Input2 = GUICtrlCreateInput("", 184, 48, 353, 21)
$Button2 = GUICtrlCreateButton("Browse", 540, 48, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label2 = GUICtrlCreateLabel("Include More :", 14, 51, 130, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label3 = GUICtrlCreateLabel("Select to exclude Audio or Video file types", 16, 91, 445, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox2 = GUICtrlCreateCheckbox("Exclude Audio/Video file types", 16, 128, 249, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
GUISetState(@SW_SHOW)
GUICtrlSetState($Checkbox2,$GUI_CHECKED)

#EndRegion ### END Koda GUI section ###

;~ Local $SourceTotalSize = DirGetSize (
;~ Local $Localvar1 = ($SourceTotalSize / 1024 )/1024
;~ Local $Localvar = StringFormat("%.2f",String ($Localvar1)) ; 43951789.00
;~ MsgBox($MB_SYSTEMMODAL, "Title", $Localvar)

If _CheckPendingCopy() = True Then
    ;GuiCtrlSetData($Edit1, " ")
    ;GuiCtrlSetData($Edit1, "Previous copy seems pending or was interupted " & @CRLF & "Do you want to Continue with previous copy or start copy again from begining")

    Local $CopyData = MsgBox($MB_YESNOCANCEL, "Alert", "Previous copy seems pending or was interupted " & @CRLF & "Press YES to continue with previous copy or NO to start from Beginining")

    If $CopyData = 6 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(True,True)
    ElseIf $CopyData = 7 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(False,False)
        _ProcessPendingCopy(False,True)
    Else
        _ProcessForm()
    EndIf
EndIf

_ProcessForm()


Func _CheckDestinationFreeSpace()
    Local $SourceTotalSize, $DestinationTotalSize
    $SourceTotalSize = DirGetSize (@DesktopDir)
    $SourceTotalSize += DirGetSize(@MyDocumentsDir)
    $SourceTotalSize += DirGetSize($Includebackup)
    $SourceTotalSize += DirGetSize(@UserProfileDir & "\Favorites")
    $SourceTotalSize += DirGetSize(@AppDataDir & "\Mozilla")
    $DestinationTotalSize= DriveSpaceFree("C:\Users\ah0126953\Downloads\Backup")
    If $DestinationTotalSize < $SourceTotalSize Then
        Return False
    Else
        Return True
    EndIf
EndFunc

Func _ReadPendingCopyDetails()
$Destination = IniRead($INIFilePath, "Destination", "Path", "")
GUICtrlSetState($Checkbox2 , IniRead($INIFilePath, "Destination","Exclude Audio/Video","1"))
GUICtrlSetData($Input2 , IniRead($INIFilePath, "Destination","Other Backup Source",""))
GUICtrlSetData($Input1 , $Destination)
EndFunc

Func _ProcessPendingCopy($IfContinuePendingCopy,$ifCopyFiles)
    if _CheckDestinationFreeSpace() Then

         _Desktop($IfContinuePendingCopy,$ifCopyFiles)
         _Favorites($IfContinuePendingCopy,$ifCopyFiles)
         _Firefox($IfContinuePendingCopy,$ifCopyFiles)
         _BackupSelection($IfContinuePendingCopy,$ifCopyFiles)
         _MyDocuments($IfContinuePendingCopy,$ifCopyFiles)
         Sleep(2000)
         GUICtrlSetData($Edit1, " ")
         GUICtrlSetData($Edit1, "Backup Completed")
         if $ifCopyFiles then
            Local $SourceSize = DirGetSize (@DesktopDir)
            ;$SourceSize += DirGetSize (@UserProfileDir & "\" )
            ;$SourceSize += DirGetSize (@MyDocumentsDir)
            MsgBox($MB_SYSTEMMODAL, "Title", $SourceSize)



            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; Must Always Be Last
                _Compress()

            EndIf

            if $Flashballoon = False Then
                TrayTip("Backup Completed", "Your Backup is completed", 10)
            EndIf
         EndIf
     Else
        ;MsgBox($MB_SYSTEMMODAL, "You do not have enough space at destination, you atleast need " & $SourceTotalSize & " MB Space")
     EndIf
EndFunc   ;==>_ProcessPendingCopy

Func _ProcessForm()
    If $Flashballoon = False Then
        TrayTip("Backup Completed", "Your Backup is completed", 10)
    EndIf

    While 1
        $nMsg = GUIGetMsg()

        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                _Exitcode()
            Case $Exit
                _Exitcode()
            Case $Button1
                _BackupDestination()
            Case $Button2
                _IncludeBackup()
            Case $BACKUP
                IniWrite($INIFilePath, "Destination", "Path", $Destination)
                IniWrite($INIFilePath, "Destination","Exclude Audio/Video",  GUICtrlRead($Checkbox2))
                IniWrite($INIFilePath, "Destination","Other Backup Source",  GUICtrlRead($Input2))


                ;iniread ($INIFilePath, "Source", "Path"
                If _Trim($Destination) = "" Then
                    GUICtrlSetData($Edit1, " ")
                    GUICtrlSetData($Edit1, "Destination path is not selected...Please select valid Destination path" & @CRLF, 1)
                    $Flag = False

                Else
                    ;_MyDocuments(False)
                    ;_Firefox(False)
                    ;_Desktop(False)
                    ;_Favorites(False)
                    ;_MsOutlook()
                    ;_BackupSelection(False)
                    _ProcessPendingCopy(False,False)
                    _ProcessPendingCopy(False,True)



                    _EnableControls()


                EndIf
        EndSwitch
    WEnd

EndFunc   ;==>_ProcessForm


Func _Exitcode()
    GUIDelete()
    Exit
EndFunc   ;==>_Exitcode

Func _Trim($LocalString)
    Return StringStripWS($LocalString, $STR_STRIPLEADING + $STR_STRIPTRAILING)
EndFunc   ;==>_Trim

Func _DisableControls()
    GUICtrlSetState($BACKUP, $GUI_DISABLE)
EndFunc   ;==>_DisableControls



Func _EnableControls()
    GUICtrlSetState($BACKUP, $GUI_ENABLE)
EndFunc   ;==>_EnableControls


Func _BackupDestination()
    $Destination = FileSelectFolder("Select backup destination", "", 7)
    if @error then Return ; #### Added in case user cancels #####
    GUICtrlSetData($Input1, $Destination)
    If DriveGetType($Destination) = "Removable" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is External one." & @CRLF & " This is against AON policy to copy data to external drives," & @CRLF & " tool will not be held responsible for not adhering AON policies" & @CRLF, 1)
    ElseIf DriveGetType($Destination) = "Network" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is on Network." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    Else
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is Local." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    EndIf

EndFunc   ;==>_BackupDestination



Func _IncludeBackup()
    $Includebackup = FileSelectFolder("Select folders to backup", "", 7)
    GUICtrlSetData($Input2, $Includebackup)
EndFunc   ;==>_IncludeBackup

Func _BackupSelection($CopyPending,$pCopyFiles)
    Local $aFileList = _FileListToArrayRec(GUICtrlRead($Input2), "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    _FileWriteLog(".\Backup.log", $Includebackup & " ..............Started ")
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, "Backing Up other selected folders" & @CRLF, 1)
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Other Backup", GUICtrlRead($Input2),$pCopyFiles)
    ;MsgBox(0,"","Done in " & TimerDiff($timer)/1000 & " seconds!")
    _FileWriteLog(".\Backup.log", GUICtrlRead($Input2) & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Manual selected backup Complete" & @CRLF, 1)
EndFunc   ;==>_BackupSelection

Func GetSourceFiles($SourceDir)
    Local $strPos = StringInStr(StringReverse($SourceDir), "\")
    Return StringMid($SourceDir, StringLen($SourceDir) - $strPos + 2, $strPos + 1)
EndFunc   ;==>GetSourceFiles


Func GetFileExtention($FileName)
    Local $strPos = StringInStr(StringReverse($FileName), ".")
    Return StringMid($FileName, StringLen($FileName) - $strPos + 1, $strPos)
EndFunc   ;==>GetSourceFiles

Func _MyDocuments($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@MyDocumentsDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    $1 = _ArraySearch($aFileList, "RECYCLER")
    _ArrayDelete($aFileList, $1)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    $2 = _ArraySearch($aFileList, "System Volume Information")
    _ArrayDelete($aFileList, $2)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users My Documents" & @CRLF, 1)
;~  DirCreate($Destination & "\MyDocuments")
    ;Call (_Copy("MyDocument"))
    ;_ArrayDisplay($aFileList, "MYDocuments")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "MyDocuments", @MyDocumentsDir,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> MyDocuments Backup Complete" & @CRLF, 1)
    $Flashballoon = False
EndFunc   ;==>_MyDocuments

Func _Favorites($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@UserProfileDir & "\Favorites", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)

    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users IE Favorites" & @CRLF, 1)
;~  DirCreate($Destination & "\Favorites")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Favorites", @UserProfileDir & "\Favorites",$pCopyFiles)
;~  MsgBox($MB_SYSTEMMODAL, "Title", $aFileList)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Favorites backup Complete" & @CRLF, 1)
EndFunc   ;==>_Favorites

Func _Desktop($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Started ")
;~  Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; #### CHANGED ####
    ; just find files (unless you want empty dirs copied?) and return the full path to the files
    Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1)
;~  DirCreate($Destination & "\Desktop") ; #### REMOVED #### no need to create

    ;_ArrayDisplay($aFileList, "Sorted tree")

    ;if $CopyPending = False then Call (_UpdateIniFile("Desktop",$aFileList))

    ;if $CopyPending then $aFileList = IniReadSection($INIfilePath,"Desktop")

    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Desktop", @DesktopDir,$pCopyFiles) ; #### send the source dir as a parameter for replacing on file copy ####

    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Desktop backup Complete" & @CRLF, 1)
EndFunc   ;==>_Desktop


Func _ProcessCurrentFolderCopy($ifCopyPending, $arrFileListToCopy, $currentFolderName, $s_SourceDir,$CopyFiles)

    If $ifCopyPending Then
        $arrFileListToCopy = IniReadSection($INIFilePath, $currentFolderName) ;read the files into a 2D array
        ;_ArrayDisplay($arrFileListToCopy, "1")
        ; delete the column that doesn't have the files in it (I think it's 1)
        _ArrayColDelete($arrFileListToCopy, 1, True) ; convert the array to a 1D
        _ArrayDisplay($arrFileListToCopy, "Array display")
        MsgBox($MB_ICONERROR, 'Copy', $arrFileListToCopy)
         _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
    Else
        if $CopyFiles then
             _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
        Else
             _UpdateIniFile($currentFolderName, $arrFileListToCopy)
        EndIf
    EndIf
;~  _ArrayDisplay($arrFileListToCopy, "Sorted tree")
    ;DirCopy(@DesktopDir, $Destination & "\Desktop", 1)
;~     Call (_Copy($currentFolderName,$arrFileListToCopy,$currentFolderName)) #### CHANGED ####

    if @error then MsgBox($MB_ICONERROR, 'Errors', 'Errors occured copying the files')

EndFunc   ;==>_ProcessCurrentFolderCopy

Func _Compress()
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Started ")
    Local $7zip = $Destination & "\7zip"
    DirCreate($7zip)
    FileInstall("tools\7za.exe", $7zip & "\7za.exe", 1)
    FileInstall("tools\7zCon.sfx", $7zip & "\7zCon.sfx", 1)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Compressing Backup" & @CRLF, 1)
    RunWait($7zip & "\7za a -r -y -sfx7zCon.sfx " & $Destination & "\Backup.exe " & $Destination & "\*.* ", "", @SW_HIDE)
    DirRemove($7zip, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Compress Data backup Complete" & @CRLF, 1)
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Completed ")
    $Flashballoon = True
EndFunc   ;==>_Compress

Func _Firefox($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Started  ")
    Local $aFileList = _FileListToArrayRec(@AppDataDir & "\Mozilla", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    ;_ArrayDisplay($aFileList, "Full array")
        GUICtrlSetData($Edit1, @CRLF, 1)
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "Backing Up Firefox Profile" & @CRLF, 1)
        If ProcessExists("firefox.exe") Then
            ProcessClose("firefox.exe")
        EndIf

        _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Firefox", @AppDataDir & "\Mozilla",$pCopyFiles)
        _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Completed ")
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "---> Firefox backup Complete" & @CRLF, 1)

    $Flashballoon = True
EndFunc   ;==>_Firefox

Func _Copy($s_SectionName, $as_FileList, $s_SourceDir)
    Local $i_Errors = 0 ; Set an error counter for file copy errors
    Local $s_Destination = GUICtrlRead($Input1) & '\' & $s_SectionName ; get the user selected destination and add the user folder
    ;_ArrayDisplay($as_FileList, "Full array")
    For $i = 1 To Ubound($as_FileList) -1
       ;MsgBox($MB_ICONERROR, 'Delete', $as_FileList[$i])
        if StringInStr(".mp3.mp4.vob.mpeg", GetFileExtention($as_FileList[$i])) = 0 OR GUICtrlRead($Checkbox2) <> $GUI_CHECKED then
            If Not FileCopy($as_FileList[$i], StringReplace(StringReplace($as_FileList[$i],"~eq~","="), $s_SourceDir, $s_Destination), $FC_OVERWRITE + $FC_CREATEPATH) Then
             $i_Errors += 1
            Else
                ; if you only delete the files successfully copied, you then have a record of those that weren't
                ; and could do something with that
                ;MsgBox($MB_ICONERROR, 'Delete1', StringReplace($as_FileList[$i],"~eq~","="))
                IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))
            EndIf
            Else
            ;MsgBox($MB_ICONERROR, 'Delete2', StringReplace($as_FileList[$i],"~eq~","="))
            IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))

        endif
    Next

    ; when the function returns you can check for @error it will tell you how many files failed to copy
    Return SetError($i_Errors)
EndFunc   ;==>_Copy


Func _UpdateIniFile($SectionName, $FileList)
    Local $CurrFileCopy

    $CurrFileCopy = IniReadSectionNames($INIFilePath)

    IniDelete($INIFilePath, $SectionName)
    For $FileCount = 1 To UBound($FileList) - 1
        IniWrite($INIFilePath, $SectionName, StringReplace($FileList[$FileCount],"=","~eq~"), $FileCount)
    Next
    FileClose($INIFilePath)

EndFunc   ;==>_UpdateIniFile


Func _CheckPendingCopy()
    Local $IsCopyPending = False
    ; Check if any key exists in any section of ini File
    $PendingKeyList = IniReadSectionNames($INIFilePath)

    If UBound($PendingKeyList) > 0 Then
        For $CurrSection In $PendingKeyList
            ; MsgBox($MB_SYSTEMMODAL, "Title", $CurrSection)
            If UBound(IniReadSection($INIFilePath, $CurrSection)) > 0 And $CurrSection <> "Destination" Then
                $IsCopyPending = True
                ExitLoop
            EndIf
        Next
    EndIf
    Return $IsCopyPending
EndFunc   ;==>_CheckPendingCopy

Edited script according to my needs but seems i missed out something....this script is not working anymore, im not able to identify where and what went wrong

Pls Help

Link to comment
Share on other sites

6 hours ago, hiteshluthraauto said:

No error, its just not do anything...seems some looping issues. As it does not do what it should...no delete nothing at all

 

That's why you need to add basic error logging, will make it easier to trace these silent errors (which it may not be)

Looking at the script it could be here CheckDestinationFreeSpace(). DirGetSize returns in bytes and DriveSpaceFree returns MB so the

If $DestinationTotalSize < $SourceTotalSize Then

will probably return false to say there isn't enough space

 

Link to comment
Share on other sites

# ;NoTrayIcon
;MsgBox($MB_SYSTEMMODAL, "Title", $test)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Backup.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3> ; #### ADDED ####
#include <GuiEdit.au3>
#include <Array.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
;#include <IniToArray.au3>

Global $sInfo
Global $Destination
Global $Includebackup
Global $Flashballoon = True
Local  $timer = TimerInit()
Global $Currfile
Global $Arrfile
Global $INIFilePath = @ScriptDir & "\CurrentDir.ini"


#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Backup", 628, 385, 441, 124)
$Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Input1 = GUICtrlCreateInput("", 184, 11, 353, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Edit1 = GUICtrlCreateEdit("", 4, 160, 613, 185)
GUICtrlSetData(-1, "---> AON Backup Tool v1")
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
$BACKUP = GUICtrlCreateButton("Backup", 454, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Exit = GUICtrlCreateButton("Exit", 536, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 16, 356, 157, 17)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetTip(-1, "Use to compress data")
$Input2 = GUICtrlCreateInput("", 184, 48, 353, 21)
$Button2 = GUICtrlCreateButton("Browse", 540, 48, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label2 = GUICtrlCreateLabel("Include More :", 14, 51, 130, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label3 = GUICtrlCreateLabel("Select to exclude Audio or Video file types", 16, 91, 445, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox2 = GUICtrlCreateCheckbox("Exclude Audio/Video file types", 16, 128, 249, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
GUISetState(@SW_SHOW)
GUICtrlSetState($Checkbox2,$GUI_CHECKED)

#EndRegion ### END Koda GUI section ###

;~ Local $SourceSize, $DestinationTotalSize,$SourceTotalSize
;~     $SourceSize = DirGetSize (@DesktopDir)
;~  $SourceSize += DirGetSize(@MyDocumentsDir)
;~  $SourceSize += DirGetSize($Includebackup)
;~  $SourceSize += DirGetSize(@UserProfileDir & "\Favorites")
;~  $SourceSize += DirGetSize(@AppDataDir & "\Mozilla")
;~  $DestinationTotalSize= DriveSpaceFree("C:\Users\ah0126953\Downloads\Backup")
;~ Local $Localvar1 = ($SourceSize / 1024 )/1024
;~ Local $SourceTotalSize = StringFormat("%.2f",String ($Localvar1)) ; 43951789.00


If _CheckPendingCopy() = True Then
    ;GuiCtrlSetData($Edit1, " ")
    ;GuiCtrlSetData($Edit1, "Previous copy seems pending or was interupted " & @CRLF & "Do you want to Continue with previous copy or start copy again from begining")

    Local $CopyData = MsgBox($MB_YESNOCANCEL, "Alert", "Previous copy seems pending or was interupted " & @CRLF & "Press YES to continue with previous copy or NO to start from Beginining")

    If $CopyData = 6 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(True,True)
    ElseIf $CopyData = 7 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(False,False)
        _ProcessPendingCopy(False,True)
    Else
        _ProcessForm()
    EndIf
EndIf

_ProcessForm()


Func _CheckDestinationFreeSpace()
    Local $SourceTotalSize, $DestinationTotalSize,$SourceSize
    $SourceSize = DirGetSize (@DesktopDir)
    $SourceSize += DirGetSize(@MyDocumentsDir)
    $SourceSize += DirGetSize($Includebackup)
    $SourceSize += DirGetSize(@UserProfileDir & "\Favorites")
    $SourceSize += DirGetSize(@AppDataDir & "\Mozilla")
    $DestinationTotalSize= DriveSpaceFree("C:\Users\ah0126953\Downloads\Backup")
    Local $Localvar1 = ($SourceSize / 1024 )/1024
    Local $SourceTotalSize = StringFormat("%.2f",String ($Localvar1)) ; 43951789.00
    MsgBox($MB_SYSTEMMODAL, "Title", $SourceTotalSize)
    MsgBox($MB_SYSTEMMODAL, "Title", $DestinationTotalSize)
    If $DestinationTotalSize < $SourceTotalSize Then
        Return False
    Else
        Return True
    EndIf
EndFunc

Func _ReadPendingCopyDetails()
$Destination = IniRead($INIFilePath, "Destination", "Path", "")
GUICtrlSetState($Checkbox2 , IniRead($INIFilePath, "Destination","Exclude Audio/Video","1"))
GUICtrlSetData($Input2 , IniRead($INIFilePath, "Destination","Other Backup Source",""))
GUICtrlSetData($Input1 , $Destination)
EndFunc

Func _ProcessPendingCopy($IfContinuePendingCopy,$ifCopyFiles)
    if _CheckDestinationFreeSpace() Then

         _Desktop($IfContinuePendingCopy,$ifCopyFiles)
         _Favorites($IfContinuePendingCopy,$ifCopyFiles)
         _Firefox($IfContinuePendingCopy,$ifCopyFiles)
         _BackupSelection($IfContinuePendingCopy,$ifCopyFiles)
         _MyDocuments($IfContinuePendingCopy,$ifCopyFiles)
         Sleep(2000)
         GUICtrlSetData($Edit1, " ")
         GUICtrlSetData($Edit1, "Backup Completed")
         if $ifCopyFiles then
            Local $SourceSize = DirGetSize (@DesktopDir)
            ;$SourceSize += DirGetSize (@UserProfileDir & "\" )
            ;$SourceSize += DirGetSize (@MyDocumentsDir)
            MsgBox($MB_SYSTEMMODAL, "Title", $SourceSize)



            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; Must Always Be Last
                _Compress()

            EndIf

            if $Flashballoon = False Then
                TrayTip("Backup Completed", "Your Backup is completed", 10)
            EndIf
         EndIf
     Else
        ;MsgBox($MB_SYSTEMMODAL, "You do not have enough space at destination, you atleast need " & $SourceTotalSize & " MB Space")
     EndIf
EndFunc   ;==>_ProcessPendingCopy

Func _ProcessForm()
    If $Flashballoon = False Then
        TrayTip("Backup Completed", "Your Backup is completed", 10)
    EndIf

    While 1
        $nMsg = GUIGetMsg()

        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                _Exitcode()
            Case $Exit
                _Exitcode()
            Case $Button1
                _BackupDestination()
            Case $Button2
                _IncludeBackup()
            Case $BACKUP
                IniWrite($INIFilePath, "Destination", "Path", $Destination)
                IniWrite($INIFilePath, "Destination","Exclude Audio/Video",  GUICtrlRead($Checkbox2))
                IniWrite($INIFilePath, "Destination","Other Backup Source",  GUICtrlRead($Input2))


                ;iniread ($INIFilePath, "Source", "Path"
                If _Trim($Destination) = "" Then
                    GUICtrlSetData($Edit1, " ")
                    GUICtrlSetData($Edit1, "Destination path is not selected...Please select valid Destination path" & @CRLF, 1)
                    $Flag = False

                Else
                    ;_MyDocuments(False)
                    ;_Firefox(False)
                    ;_Desktop(False)
                    ;_Favorites(False)
                    ;_MsOutlook()
                    ;_BackupSelection(False)
                    _ProcessPendingCopy(False,False)
                    _ProcessPendingCopy(False,True)



                    _EnableControls()


                EndIf
        EndSwitch
    WEnd

EndFunc   ;==>_ProcessForm


Func _Exitcode()
    GUIDelete()
    Exit
EndFunc   ;==>_Exitcode

Func _Trim($LocalString)
    Return StringStripWS($LocalString, $STR_STRIPLEADING + $STR_STRIPTRAILING)
EndFunc   ;==>_Trim

Func _DisableControls()
    GUICtrlSetState($BACKUP, $GUI_DISABLE)
EndFunc   ;==>_DisableControls



Func _EnableControls()
    GUICtrlSetState($BACKUP, $GUI_ENABLE)
EndFunc   ;==>_EnableControls


Func _BackupDestination()
    $Destination = FileSelectFolder("Select backup destination", "", 7)
    if @error then Return ; #### Added in case user cancels #####
    GUICtrlSetData($Input1, $Destination)
    If DriveGetType($Destination) = "Removable" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is External one." & @CRLF & " This is against AON policy to copy data to external drives," & @CRLF & " tool will not be held responsible for not adhering AON policies" & @CRLF, 1)
    ElseIf DriveGetType($Destination) = "Network" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is on Network." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    Else
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is Local." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    EndIf

EndFunc   ;==>_BackupDestination



Func _IncludeBackup()
    $Includebackup = FileSelectFolder("Select folders to backup", "", 7)
    GUICtrlSetData($Input2, $Includebackup)
EndFunc   ;==>_IncludeBackup

Func _BackupSelection($CopyPending,$pCopyFiles)
    Local $aFileList = _FileListToArrayRec(GUICtrlRead($Input2), "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    _FileWriteLog(".\Backup.log", $Includebackup & " ..............Started ")
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, "Backing Up other selected folders" & @CRLF, 1)
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Other Backup", GUICtrlRead($Input2),$pCopyFiles)
    ;MsgBox(0,"","Done in " & TimerDiff($timer)/1000 & " seconds!")
    _FileWriteLog(".\Backup.log", GUICtrlRead($Input2) & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Manual selected backup Complete" & @CRLF, 1)
EndFunc   ;==>_BackupSelection

Func GetSourceFiles($SourceDir)
    Local $strPos = StringInStr(StringReverse($SourceDir), "\")
    Return StringMid($SourceDir, StringLen($SourceDir) - $strPos + 2, $strPos + 1)
EndFunc   ;==>GetSourceFiles


Func GetFileExtention($FileName)
    Local $strPos = StringInStr(StringReverse($FileName), ".")
    Return StringMid($FileName, StringLen($FileName) - $strPos + 1, $strPos)
EndFunc   ;==>GetSourceFiles

Func _MyDocuments($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@MyDocumentsDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    $1 = _ArraySearch($aFileList, "RECYCLER")
    _ArrayDelete($aFileList, $1)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    $2 = _ArraySearch($aFileList, "System Volume Information")
    _ArrayDelete($aFileList, $2)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users My Documents" & @CRLF, 1)
;~  DirCreate($Destination & "\MyDocuments")
    ;Call (_Copy("MyDocument"))
    ;_ArrayDisplay($aFileList, "MYDocuments")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "MyDocuments", @MyDocumentsDir,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> MyDocuments Backup Complete" & @CRLF, 1)
    $Flashballoon = False
EndFunc   ;==>_MyDocuments

Func _Favorites($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@UserProfileDir & "\Favorites", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)

    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users IE Favorites" & @CRLF, 1)
;~  DirCreate($Destination & "\Favorites")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Favorites", @UserProfileDir & "\Favorites",$pCopyFiles)
;~  MsgBox($MB_SYSTEMMODAL, "Title", $aFileList)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Favorites backup Complete" & @CRLF, 1)
EndFunc   ;==>_Favorites

Func _Desktop($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Started ")
;~  Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; #### CHANGED ####
    ; just find files (unless you want empty dirs copied?) and return the full path to the files
    Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1)
;~  DirCreate($Destination & "\Desktop") ; #### REMOVED #### no need to create

    ;_ArrayDisplay($aFileList, "Sorted tree")

    ;if $CopyPending = False then Call (_UpdateIniFile("Desktop",$aFileList))

    ;if $CopyPending then $aFileList = IniReadSection($INIfilePath,"Desktop")

    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Desktop", @DesktopDir,$pCopyFiles) ; #### send the source dir as a parameter for replacing on file copy ####

    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Desktop backup Complete" & @CRLF, 1)
EndFunc   ;==>_Desktop


Func _ProcessCurrentFolderCopy($ifCopyPending, $arrFileListToCopy, $currentFolderName, $s_SourceDir,$CopyFiles)

    If $ifCopyPending Then
        $arrFileListToCopy = IniReadSection($INIFilePath, $currentFolderName) ;read the files into a 2D array
        ;_ArrayDisplay($arrFileListToCopy, "1")
        ; delete the column that doesn't have the files in it (I think it's 1)
        _ArrayColDelete($arrFileListToCopy, 1, True) ; convert the array to a 1D
        _ArrayDisplay($arrFileListToCopy, "Array display")
        MsgBox($MB_ICONERROR, 'Copy', $arrFileListToCopy)
         _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
    Else
        if $CopyFiles then
             _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
        Else
             _UpdateIniFile($currentFolderName, $arrFileListToCopy)
        EndIf
    EndIf
;~  _ArrayDisplay($arrFileListToCopy, "Sorted tree")
    ;DirCopy(@DesktopDir, $Destination & "\Desktop", 1)
;~     Call (_Copy($currentFolderName,$arrFileListToCopy,$currentFolderName)) #### CHANGED ####

    if @error then MsgBox($MB_ICONERROR, 'Errors', 'Errors occured copying the files')

EndFunc   ;==>_ProcessCurrentFolderCopy

Func _Compress()
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Started ")
    Local $7zip = $Destination & "\7zip"
    DirCreate($7zip)
    FileInstall("tools\7za.exe", $7zip & "\7za.exe", 1)
    FileInstall("tools\7zCon.sfx", $7zip & "\7zCon.sfx", 1)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Compressing Backup" & @CRLF, 1)
    RunWait($7zip & "\7za a -r -y -sfx7zCon.sfx " & $Destination & "\Backup.exe " & $Destination & "\*.* ", "", @SW_HIDE)
    DirRemove($7zip, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Compress Data backup Complete" & @CRLF, 1)
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Completed ")
    $Flashballoon = True
EndFunc   ;==>_Compress

Func _Firefox($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Started  ")
    Local $aFileList = _FileListToArrayRec(@AppDataDir & "\Mozilla", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    ;_ArrayDisplay($aFileList, "Full array")
        GUICtrlSetData($Edit1, @CRLF, 1)
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "Backing Up Firefox Profile" & @CRLF, 1)
        If ProcessExists("firefox.exe") Then
            ProcessClose("firefox.exe")
        EndIf

        _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Firefox", @AppDataDir & "\Mozilla",$pCopyFiles)
        _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Completed ")
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "---> Firefox backup Complete" & @CRLF, 1)

    $Flashballoon = True
EndFunc   ;==>_Firefox

Func _Copy($s_SectionName, $as_FileList, $s_SourceDir)
    Local $i_Errors = 0 ; Set an error counter for file copy errors
    Local $s_Destination = GUICtrlRead($Input1) & '\' & $s_SectionName ; get the user selected destination and add the user folder
    ;_ArrayDisplay($as_FileList, "Full array")
    For $i = 1 To Ubound($as_FileList) -1
       ;MsgBox($MB_ICONERROR, 'Delete', $as_FileList[$i])
        if StringInStr(".mp3.mp4.vob.mpeg", GetFileExtention($as_FileList[$i])) = 0 OR GUICtrlRead($Checkbox2) <> $GUI_CHECKED then
            If Not FileCopy($as_FileList[$i], StringReplace(StringReplace($as_FileList[$i],"~eq~","="), $s_SourceDir, $s_Destination), $FC_OVERWRITE + $FC_CREATEPATH) Then
             $i_Errors += 1
            Else
                ; if you only delete the files successfully copied, you then have a record of those that weren't
                ; and could do something with that
                ;MsgBox($MB_ICONERROR, 'Delete1', StringReplace($as_FileList[$i],"~eq~","="))
                IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))
            EndIf
            Else
            ;MsgBox($MB_ICONERROR, 'Delete2', StringReplace($as_FileList[$i],"~eq~","="))
            IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))

        endif
    Next

    ; when the function returns you can check for @error it will tell you how many files failed to copy
    Return SetError($i_Errors)
EndFunc   ;==>_Copy


Func _UpdateIniFile($SectionName, $FileList)
    Local $CurrFileCopy

    $CurrFileCopy = IniReadSectionNames($INIFilePath)

    IniDelete($INIFilePath, $SectionName)
    For $FileCount = 1 To UBound($FileList) - 1
        IniWrite($INIFilePath, $SectionName, StringReplace($FileList[$FileCount],"=","~eq~"), $FileCount)
    Next
    FileClose($INIFilePath)

EndFunc   ;==>_UpdateIniFile


Func _CheckPendingCopy()
    Local $IsCopyPending = False
    ; Check if any key exists in any section of ini File
    $PendingKeyList = IniReadSectionNames($INIFilePath)

    If UBound($PendingKeyList) > 0 Then
        For $CurrSection In $PendingKeyList
            ; MsgBox($MB_SYSTEMMODAL, "Title", $CurrSection)
            If UBound(IniReadSection($INIFilePath, $CurrSection)) > 0 And $CurrSection <> "Destination" Then
                $IsCopyPending = True
                ExitLoop
            EndIf
        Next
    EndIf
    Return $IsCopyPending
EndFunc   ;==>_CheckPendingCopy

Here is my modified script. i do not know how i can do error logging and also require script debug technology.

Link to comment
Share on other sites

The help file has return values and error values for the AutoIt functions, you can use this info to check that the return you were expecting is actually the one you get.

One example would be _FileListToArrayRec. On failure this has multiple @extended return values, and if the parameters you passed to the function are correct the ones to check for will be 1 and 9.  You could also check that an array was returned, as if you try to action the non array variable, your program will end and a usual error message given is ;

Quote

Subscript used with non-Array variable

In your _Desktop function you have

Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
 GUICtrlSetData($Edit1, @CRLF, 1)
 GUICtrlSetData($Edit1, " ")
 GUICtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1)

there are no checks to ensure an array was returned. You then pass the assumed array eventually on to _Copy function (as $as_FileList). In this function you then loop through the array and copy the files\folders using

For $i = 1 To Ubound($as_FileList) -1
 ; copy file code here
 Next

If $as_FileList is not an array you won't be able to access the [$i] element, ($as_FileList[$i])

A simple check would be

Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)  
 if Not IsArray($aFileList) Then Return Seterror(@error, @extended, 'Doh!, something went wrong')

The calling function could then check for errors on return from _Copy and give feedback.

For debugging, I normally use msgbox, consolewrite or _arraydisplay, there are loads of threads on the forum such as this

Link to comment
Share on other sites

Ok benners...will try that too in script

 

Btw, i want to include documentation in this script...i mean a help file or something or description about this tool. How can i include that one so that i only have one exe file which includes documentation too.?

Link to comment
Share on other sites

If it is just a description of the program you could have an about button, icon or you could give the program a menu using GUICtrlCreateMenu, (bit over the top for just one entry though). The about action could be to open a gui or a message box with the info you want to display such as, program name, version, author, basic instructions for use.

If you wanted to create a separate help file, be it a small text file or one like that which comes with AutoIt, you could use FileInstall to include at compile time and extract at run time.

Link to comment
Share on other sites

I want to include help file in chm or docx format, have tried multiple options including fiieinstall(). it actually works but when only when help file in available on the same path. ITs just not getting included while compiling ... it should be only one exe file after compiling and should also have help file in it.

# ;NoTrayIcon
;MsgBox($MB_SYSTEMMODAL, "Title", $test)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Backup.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3> ; #### ADDED ####
#include <GuiEdit.au3>
#include <Array.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
;#include <C:\Users\ah0126953\Desktop\Help.chm>
;#include <Word.au3>
#AutoIt3Wrapper_Res_File_Add="C:\Users\ah0126953\Desktop\Help.chm", 10


Global $sInfo
Global $Destination
Global $Includebackup
Global $Flashballoon = True
Local  $timer = TimerInit()
Global $Currfile
Global $Arrfile
Global $INIFilePath = @ScriptDir & "\CurrentDir.ini"
Local $HelpFlag = 1
;FileInstall("Help.chm", @TempDir & "Help.chm",1)


#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Backup", 629, 386, 441, 124)
$Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Input1 = GUICtrlCreateInput("", 184, 11, 353, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Edit1 = GUICtrlCreateEdit("", 4, 160, 613, 185)
GUICtrlSetData(-1, "---> AON Backup Tool v1")
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
$BACKUP = GUICtrlCreateButton("Backup", 454, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Exit = GUICtrlCreateButton("Exit", 536, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 16, 356, 157, 17)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetTip(-1, "Use to compress data")
$Input2 = GUICtrlCreateInput("", 184, 48, 353, 21)
$Button2 = GUICtrlCreateButton("Browse", 540, 48, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label2 = GUICtrlCreateLabel("Include More :", 14, 51, 130, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label3 = GUICtrlCreateLabel("Select to exclude Audio or Video file types", 16, 91, 445, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox2 = GUICtrlCreateCheckbox("Exclude Audio/Video file types", 16, 128, 249, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
$Checkbox3 = GUICtrlCreateCheckbox("Show help", 532, 128, 81, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
GUICtrlSetState($Checkbox2,$GUI_CHECKED)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ #Region ### START Koda GUI section ### Form=
;~ $Form1_1 = GUICreate("Backup", 628, 385, 441, 124)
;~ $Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE))
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Input1 = GUICtrlCreateInput("", 184, 11, 353, 23)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Edit1 = GUICtrlCreateEdit("", 4, 160, 613, 185)
;~ GUICtrlSetData(-1, "---> AON Backup Tool v1")
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ GUICtrlSetColor(-1, 0x00FF00)
;~ GUICtrlSetBkColor(-1, 0x000000)
;~ $BACKUP = GUICtrlCreateButton("Backup", 454, 352, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Exit = GUICtrlCreateButton("Exit", 536, 352, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 16, 356, 157, 17)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ GUICtrlSetTip(-1, "Use to compress data")
;~ $Input2 = GUICtrlCreateInput("", 184, 48, 353, 21)
;~ $Button2 = GUICtrlCreateButton("Browse", 540, 48, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Label2 = GUICtrlCreateLabel("Include More :", 14, 51, 130, 19)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Label3 = GUICtrlCreateLabel("Select to exclude Audio or Video file types", 16, 91, 445, 19)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Checkbox2 = GUICtrlCreateCheckbox("Exclude Audio/Video file types", 16, 128, 249, 17)
;~ GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
;~ GUISetState(@SW_SHOW)
;~ GUICtrlSetState($Checkbox2,$GUI_CHECKED)

;~ #EndRegion ### END Koda GUI section ###

;~ Local $SourceSize, $DestinationTotalSize,$SourceTotalSize
;~     $SourceSize = DirGetSize (@DesktopDir)
;~  $SourceSize += DirGetSize(@MyDocumentsDir)
;~  $SourceSize += DirGetSize($Includebackup)
;~  $SourceSize += DirGetSize(@UserProfileDir & "\Favorites")
;~  $SourceSize += DirGetSize(@AppDataDir & "\Mozilla")
;~  $DestinationTotalSize= DriveSpaceFree("C:\Users\ah0126953\Downloads\Backup")
;~ Local $Localvar1 = ($SourceSize / 1024 )/1024
;~ Local $SourceTotalSize = StringFormat("%.2f",String ($Localvar1)) ; 43951789.00



If _CheckPendingCopy() = True Then
    ;GuiCtrlSetData($Edit1, " ")
    ;GuiCtrlSetData($Edit1, "Previous copy seems pending or was interupted " & @CRLF & "Do you want to Continue with previous copy or start copy again from begining")

    Local $CopyData = MsgBox($MB_YESNOCANCEL, "Alert", "Previous copy seems pending or was interupted " & @CRLF & "Press YES to continue with previous copy or NO to start from Beginining")

    If $CopyData = 6 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(True,True)
    ElseIf $CopyData = 7 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(False,False)
        _ProcessPendingCopy(False,True)
    Else
        _ProcessForm()
    EndIf
EndIf

_ProcessForm()


Func _CheckDestinationFreeSpace()
    Local $SourceTotalSize, $DestinationTotalSize,$SourceSize
    $SourceSize = DirGetSize (@DesktopDir)
    $SourceSize += DirGetSize(@MyDocumentsDir)
    $SourceSize += DirGetSize($Includebackup)
    $SourceSize += DirGetSize(@UserProfileDir & "\Favorites")
    $SourceSize += DirGetSize(@AppDataDir & "\Mozilla")
    $DestinationTotalSize= DriveSpaceFree("C:\Users\ah0126953\Downloads\Backup")
    Local $Localvar1 = ($SourceSize / 1024 )/1024
    Local $SourceTotalSize = StringFormat("%.2f",String ($Localvar1)) ; 43951789.00

    If $DestinationTotalSize < $SourceTotalSize Then
        Return False
    Else
        Return True
    EndIf
EndFunc

Func _ReadPendingCopyDetails()
$Destination = IniRead($INIFilePath, "Destination", "Path", "")
GUICtrlSetState($Checkbox2 , IniRead($INIFilePath, "Destination","Exclude Audio/Video","1"))
GUICtrlSetData($Input2 , IniRead($INIFilePath, "Destination","Other Backup Source",""))
GUICtrlSetData($Input1 , $Destination)
EndFunc

Func _ProcessPendingCopy($IfContinuePendingCopy,$ifCopyFiles)
    if _CheckDestinationFreeSpace() Then

         _Desktop($IfContinuePendingCopy,$ifCopyFiles)
         _Favorites($IfContinuePendingCopy,$ifCopyFiles)
         _Firefox($IfContinuePendingCopy,$ifCopyFiles)
         _BackupSelection($IfContinuePendingCopy,$ifCopyFiles)
         _MyDocuments($IfContinuePendingCopy,$ifCopyFiles)
         Sleep(2000)
         GUICtrlSetData($Edit1, " ")
         GUICtrlSetData($Edit1, "Backup Completed")
         if $ifCopyFiles then
            Local $SourceSize = DirGetSize (@DesktopDir)




            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; Must Always Be Last
                _Compress()

            EndIf

            if $Flashballoon = False Then
                TrayTip("Backup Completed", "Your Backup is completed", 10)
            EndIf
         EndIf
     Else
        ;MsgBox($MB_SYSTEMMODAL, "You do not have enough space at destination, you atleast need " & $SourceTotalSize & " MB Space")
     EndIf
EndFunc   ;==>_ProcessPendingCopy

Func _ProcessForm()
    If $Flashballoon = False Then
        TrayTip("Backup Completed", "Your Backup is completed", 10)
    EndIf

    While 1
        $nMsg = GUIGetMsg()
                If GUICtrlRead($Checkbox3) = $GUI_CHECKED  and  $HelpFlag = 1 Then ; Must Always Be Last
                    GUICtrlSetState($Checkbox3,$GUI_DISABLE)

                    $HelpFlag = 2

                    _OpenHelp()

                EndIf
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                _Exitcode()
            Case $Exit
                _Exitcode()
            Case $Button1
                _BackupDestination()
            Case $Button2
                _IncludeBackup()
            Case $BACKUP
                IniWrite($INIFilePath, "Destination", "Path", $Destination)
                IniWrite($INIFilePath, "Destination","Exclude Audio/Video",  GUICtrlRead($Checkbox2))
                IniWrite($INIFilePath, "Destination","Other Backup Source",  GUICtrlRead($Input2))


                ;iniread ($INIFilePath, "Source", "Path"
                If _Trim($Destination) = "" Then
                    GUICtrlSetData($Edit1, " ")
                    GUICtrlSetData($Edit1, "Destination path is not selected...Please select valid Destination path" & @CRLF, 1)
                    $Flag = False

                Else
                    ;_MyDocuments(False)
                    ;_Firefox(False)
                    ;_Desktop(False)
                    ;_Favorites(False)
                    ;_MsOutlook()
                    ;_BackupSelection(False)
                    _ProcessPendingCopy(False,False)
                    _ProcessPendingCopy(False,True)



                    _EnableControls()


                EndIf

        EndSwitch
    WEnd

EndFunc   ;==>_ProcessForm

Func _OpenHelp()
;~  Local $oWord = _Word_Create()
;~  Local $sDocument = @ScriptDir & "\Help.docx"
ShellExecute("hh.exe", "Help.chm")
;~  _Word_DocOpen($oWord, $sDocument, Default, Default, True)
;GUISetHelp('hh.exe "' & @ScriptDir & '\Help.chm"')

    ;GUISetState(@SW_SHOW) ; will display an empty dialog box
EndFunc
Func _Exitcode()
    GUIDelete()
    Exit
EndFunc   ;==>_Exitcode

Func _Trim($LocalString)
    Return StringStripWS($LocalString, $STR_STRIPLEADING + $STR_STRIPTRAILING)
EndFunc   ;==>_Trim

Func _DisableControls()
    GUICtrlSetState($BACKUP, $GUI_DISABLE)
EndFunc   ;==>_DisableControls



Func _EnableControls()
    GUICtrlSetState($BACKUP, $GUI_ENABLE)
EndFunc   ;==>_EnableControls


Func _BackupDestination()
    $Destination = FileSelectFolder("Select backup destination", "", 7)
    if @error then Return ; #### Added in case user cancels #####
    GUICtrlSetData($Input1, $Destination)
    If DriveGetType($Destination) = "Removable" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is External one." & @CRLF & " This is against AON policy to copy data to external drives," & @CRLF & " tool will not be held responsible for not adhering AON policies" & @CRLF, 1)
    ElseIf DriveGetType($Destination) = "Network" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is on Network." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    Else
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is Local." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    EndIf

EndFunc   ;==>_BackupDestination



Func _IncludeBackup()
    $Includebackup = FileSelectFolder("Select folders to backup", "", 7)
    GUICtrlSetData($Input2, $Includebackup)
EndFunc   ;==>_IncludeBackup

Func _BackupSelection($CopyPending,$pCopyFiles)
    Local $aFileList = _FileListToArrayRec(GUICtrlRead($Input2), "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    _FileWriteLog(".\Backup.log", $Includebackup & " ..............Started ")
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, "Backing Up other selected folders" & @CRLF, 1)
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Other Backup", GUICtrlRead($Input2),$pCopyFiles)
    ;MsgBox(0,"","Done in " & TimerDiff($timer)/1000 & " seconds!")
    _FileWriteLog(".\Backup.log", GUICtrlRead($Input2) & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Manual selected backup Complete" & @CRLF, 1)
EndFunc   ;==>_BackupSelection

Func GetSourceFiles($SourceDir)
    Local $strPos = StringInStr(StringReverse($SourceDir), "\")
    Return StringMid($SourceDir, StringLen($SourceDir) - $strPos + 2, $strPos + 1)
EndFunc   ;==>GetSourceFiles


Func GetFileExtention($FileName)
    Local $strPos = StringInStr(StringReverse($FileName), ".")
    Return StringMid($FileName, StringLen($FileName) - $strPos + 1, $strPos)
EndFunc   ;==>GetSourceFiles

Func _MyDocuments($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@MyDocumentsDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    $1 = _ArraySearch($aFileList, "RECYCLER")
    _ArrayDelete($aFileList, $1)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    $2 = _ArraySearch($aFileList, "System Volume Information")
    _ArrayDelete($aFileList, $2)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users My Documents" & @CRLF, 1)
;~  DirCreate($Destination & "\MyDocuments")
    ;Call (_Copy("MyDocument"))
    ;_ArrayDisplay($aFileList, "MYDocuments")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "MyDocuments", @MyDocumentsDir,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> MyDocuments Backup Complete" & @CRLF, 1)
    $Flashballoon = False
EndFunc   ;==>_MyDocuments

Func _Favorites($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@UserProfileDir & "\Favorites", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)

    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users IE Favorites" & @CRLF, 1)
;~  DirCreate($Destination & "\Favorites")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Favorites", @UserProfileDir & "\Favorites",$pCopyFiles)
;~  MsgBox($MB_SYSTEMMODAL, "Title", $aFileList)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Favorites backup Complete" & @CRLF, 1)
EndFunc   ;==>_Favorites

Func _Desktop($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Started ")
;~  Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; #### CHANGED ####
    ; just find files (unless you want empty dirs copied?) and return the full path to the files
    Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1)
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Desktop", @DesktopDir,$pCopyFiles) ; #### send the source dir as a parameter for replacing on file copy ####

    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Desktop backup Complete" & @CRLF, 1)
EndFunc   ;==>_Desktop


Func _ProcessCurrentFolderCopy($ifCopyPending, $arrFileListToCopy, $currentFolderName, $s_SourceDir,$CopyFiles)

    If $ifCopyPending Then
        $arrFileListToCopy = IniReadSection($INIFilePath, $currentFolderName) ;read the files into a 2D array
        ;_ArrayDisplay($arrFileListToCopy, "1")
        ; delete the column that doesn't have the files in it (I think it's 1)
        _ArrayColDelete($arrFileListToCopy, 1, True) ; convert the array to a 1D
        ;_ArrayDisplay($arrFileListToCopy, "Array display")
        ;MsgBox($MB_ICONERROR, 'Copy', $arrFileListToCopy)
         _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
    Else
        if $CopyFiles then
             _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
        Else
             _UpdateIniFile($currentFolderName, $arrFileListToCopy)
        EndIf
    EndIf
;~  _ArrayDisplay($arrFileListToCopy, "Sorted tree")
    ;DirCopy(@DesktopDir, $Destination & "\Desktop", 1)
;~     Call (_Copy($currentFolderName,$arrFileListToCopy,$currentFolderName)) #### CHANGED ####

    if @error then MsgBox($MB_ICONERROR, 'Errors', 'Errors occured copying the files')

EndFunc   ;==>_ProcessCurrentFolderCopy

Func _Compress()
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Started ")
    Local $7zip = $Destination & "\7zip"
    DirCreate($7zip)
    FileInstall("tools\7za.exe", $7zip & "\7za.exe", 1)
    FileInstall("tools\7zCon.sfx", $7zip & "\7zCon.sfx", 1)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Compressing Backup" & @CRLF, 1)
    RunWait($7zip & "\7za a -r -y -sfx7zCon.sfx " & $Destination & "\Backup.exe " & $Destination & "\*.* ", "", @SW_HIDE)
    DirRemove($7zip, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Compress Data backup Complete" & @CRLF, 1)
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Completed ")
    $Flashballoon = True
EndFunc   ;==>_Compress

Func _Firefox($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Started  ")
    Local $aFileList = _FileListToArrayRec(@AppDataDir & "\Mozilla", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    ;_ArrayDisplay($aFileList, "Full array")
        GUICtrlSetData($Edit1, @CRLF, 1)
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "Backing Up Firefox Profile" & @CRLF, 1)
        If ProcessExists("firefox.exe") Then
            ProcessClose("firefox.exe")
        EndIf

        _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Firefox", @AppDataDir & "\Mozilla",$pCopyFiles)
        _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Completed ")
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "---> Firefox backup Complete" & @CRLF, 1)

    $Flashballoon = True
EndFunc   ;==>_Firefox

Func _Copy($s_SectionName, $as_FileList, $s_SourceDir)
    Local $i_Errors = 0 ; Set an error counter for file copy errors
    Local $s_Destination = GUICtrlRead($Input1) & '\' & $s_SectionName ; get the user selected destination and add the user folder
    ;_ArrayDisplay($as_FileList, "Full array")
    For $i = 1 To Ubound($as_FileList) -1
       ;MsgBox($MB_ICONERROR, 'Delete', $as_FileList[$i])
        if StringInStr(".mp3.mp4.vob.mpeg", GetFileExtention($as_FileList[$i])) = 0 OR GUICtrlRead($Checkbox2) <> $GUI_CHECKED then
            If Not FileCopy($as_FileList[$i], StringReplace(StringReplace($as_FileList[$i],"~eq~","="), $s_SourceDir, $s_Destination), $FC_OVERWRITE + $FC_CREATEPATH) Then
             $i_Errors += 1
            Else
                ; if you only delete the files successfully copied, you then have a record of those that weren't
                ; and could do something with that
                ;MsgBox($MB_ICONERROR, 'Delete1', StringReplace($as_FileList[$i],"~eq~","="))
                IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))
            EndIf
            Else
            ;MsgBox($MB_ICONERROR, 'Delete2', StringReplace($as_FileList[$i],"~eq~","="))
            IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))

        endif
    Next

    ; when the function returns you can check for @error it will tell you how many files failed to copy
    Return SetError($i_Errors)
EndFunc   ;==>_Copy


Func _UpdateIniFile($SectionName, $FileList)
    Local $CurrFileCopy

    $CurrFileCopy = IniReadSectionNames($INIFilePath)

    IniDelete($INIFilePath, $SectionName)
    For $FileCount = 1 To UBound($FileList) - 1
        IniWrite($INIFilePath, $SectionName, StringReplace($FileList[$FileCount],"=","~eq~"), $FileCount)
    Next
    FileClose($INIFilePath)

EndFunc   ;==>_UpdateIniFile


Func _CheckPendingCopy()
    Local $IsCopyPending = False
    ; Check if any key exists in any section of ini File
    $PendingKeyList = IniReadSectionNames($INIFilePath)

    If UBound($PendingKeyList) > 0 Then
        For $CurrSection In $PendingKeyList
            ; MsgBox($MB_SYSTEMMODAL, "Title", $CurrSection)
            If UBound(IniReadSection($INIFilePath, $CurrSection)) > 0 And $CurrSection <> "Destination" Then
                $IsCopyPending = True
                ExitLoop
            EndIf
        Next
    EndIf
    Return $IsCopyPending
EndFunc   ;==>_CheckPendingCopy

 

Link to comment
Share on other sites

No probs. I would use a hotkey for the help file

HotKeySet('{F1}', '_OpenHelp') ; Hotkey to open the help file.

You can then just have a label saying "F1 for help". If you use a check box, you have to keep unchecking and checking to get the help file up.

Link to comment
Share on other sites

Thanks Benners,

I got it working in another way.

Background : This script take path of all source directories and place them into config file so that it can delete filenames when data is copied (if tool is interrupted in between) and thats the reason i gave this option which was working good but seems i messed up lil. This tool also compress data after its backed up onto destination

There are two issues with the script:

1) when i interrupt this tool in between and want to continue where i left it does not copy all files and thats the reason have some filenames pending in ini file too. I am unsure where is the issue, also tried to error and return values but they didn't help much. You can check by terminating this tool while its copying files...and next time when you see msg prompt to continue where you left off...you should see non copied file names in ini file.

2) what i want is to copy all data to somewhere in laptop (if compress option is checked) and compress it there only , after compression it should copy compress data to destination..rather then copy all data to destination and then compress.

I want to know if you can help me in this to ulter so that it is finally final. i Know i have connected with you lot of times but will appreciate if you can help here.

 

# ;NoTrayIcon
;MsgBox($MB_SYSTEMMODAL, "Title", $test)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Backup.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3> ; #### ADDED ####
#include <GuiEdit.au3>
#include <Array.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
;#include <C:\Users\ah0126953\Desktop\Help.chm>
;#include <Word.au3>
#AutoIt3Wrapper_Res_File_Add="C:\Users\ah0126953\Desktop\Help.chm", 10


Global $sInfo
Global $Destination
Global $Includebackup
Global $Flashballoon = True
Local  $timer = TimerInit()
Global $Currfile
Global $Arrfile
Global $INIFilePath = @ScriptDir & "\CurrentDir.ini"
Local $HelpFlag = 1
FileInstall("Help.chm", @TempDir & "\Help.chm",1)


#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Backup", 629, 386, 441, 124)
$Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Input1 = GUICtrlCreateInput("", 184, 11, 353, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Edit1 = GUICtrlCreateEdit("", 4, 160, 613, 185)
GUICtrlSetData(-1, "---> AON Backup Tool v1")
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
$BACKUP = GUICtrlCreateButton("Backup", 454, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Exit = GUICtrlCreateButton("Exit", 536, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 16, 356, 157, 17)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetTip(-1, "Use to compress data")
$Input2 = GUICtrlCreateInput("", 184, 48, 353, 21)
$Button2 = GUICtrlCreateButton("Browse", 540, 48, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label2 = GUICtrlCreateLabel("Include More :", 14, 51, 130, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label3 = GUICtrlCreateLabel("Select to exclude Audio or Video file types", 16, 91, 445, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox2 = GUICtrlCreateCheckbox("Exclude Audio/Video file types", 16, 128, 249, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
$Checkbox3 = GUICtrlCreateCheckbox("Show help", 532, 128, 81, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
GUICtrlSetState($Checkbox2,$GUI_CHECKED)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ #Region ### START Koda GUI section ### Form=
;~ $Form1_1 = GUICreate("Backup", 628, 385, 441, 124)
;~ $Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE))
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Input1 = GUICtrlCreateInput("", 184, 11, 353, 23)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Edit1 = GUICtrlCreateEdit("", 4, 160, 613, 185)
;~ GUICtrlSetData(-1, "---> AON Backup Tool v1")
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ GUICtrlSetColor(-1, 0x00FF00)
;~ GUICtrlSetBkColor(-1, 0x000000)
;~ $BACKUP = GUICtrlCreateButton("Backup", 454, 352, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Exit = GUICtrlCreateButton("Exit", 536, 352, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 16, 356, 157, 17)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ GUICtrlSetTip(-1, "Use to compress data")
;~ $Input2 = GUICtrlCreateInput("", 184, 48, 353, 21)
;~ $Button2 = GUICtrlCreateButton("Browse", 540, 48, 75, 25)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Label2 = GUICtrlCreateLabel("Include More :", 14, 51, 130, 19)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Label3 = GUICtrlCreateLabel("Select to exclude Audio or Video file types", 16, 91, 445, 19)
;~ GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
;~ $Checkbox2 = GUICtrlCreateCheckbox("Exclude Audio/Video file types", 16, 128, 249, 17)
;~ GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
;~ GUISetState(@SW_SHOW)
;~ GUICtrlSetState($Checkbox2,$GUI_CHECKED)

;~ #EndRegion ### END Koda GUI section ###

;~ Local $SourceSize, $DestinationTotalSize,$SourceTotalSize
;~     $SourceSize = DirGetSize (@DesktopDir)
;~  $SourceSize += DirGetSize(@MyDocumentsDir)
;~  $SourceSize += DirGetSize($Includebackup)
;~  $SourceSize += DirGetSize(@UserProfileDir & "\Favorites")
;~  $SourceSize += DirGetSize(@AppDataDir & "\Mozilla")
;~  $DestinationTotalSize= DriveSpaceFree("C:\Users\ah0126953\Downloads\Backup")
;~ Local $Localvar1 = ($SourceSize / 1024 )/1024
;~ Local $SourceTotalSize = StringFormat("%.2f",String ($Localvar1)) ; 43951789.00



If _CheckPendingCopy() = True Then
    ;GuiCtrlSetData($Edit1, " ")
    ;GuiCtrlSetData($Edit1, "Previous copy seems pending or was interupted " & @CRLF & "Do you want to Continue with previous copy or start copy again from begining")

    Local $CopyData = MsgBox($MB_YESNOCANCEL, "Alert", "Previous copy seems pending or was interupted " & @CRLF & "Press YES to continue with previous copy or NO to start from Beginining")

    If $CopyData = 6 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(True,True)
    ElseIf $CopyData = 7 Then
        _ReadPendingCopyDetails()
        _ProcessPendingCopy(False,False)
        _ProcessPendingCopy(False,True)
    Else
        _ProcessForm()
    EndIf
EndIf

_ProcessForm()


Func _CheckDestinationFreeSpace()
    Local $SourceTotalSize, $DestinationTotalSize,$SourceSize
    $SourceSize = DirGetSize (@DesktopDir)
    $SourceSize += DirGetSize(@MyDocumentsDir)
    $SourceSize += DirGetSize($Includebackup)
    $SourceSize += DirGetSize(@UserProfileDir & "\Favorites")
    $SourceSize += DirGetSize(@AppDataDir & "\Mozilla")
    $DestinationTotalSize= DriveSpaceFree("C:\Users\ah0126953\Downloads\Backup")
    Local $Localvar1 = ($SourceSize / 1024 )/1024
    Local $SourceTotalSize = StringFormat("%.2f",String ($Localvar1)) ; 43951789.00

    If $DestinationTotalSize < $SourceTotalSize Then
        Return False
    Else
        Return True
    EndIf
EndFunc

Func _ReadPendingCopyDetails()
$Destination = IniRead($INIFilePath, "Destination", "Path", "")
GUICtrlSetState($Checkbox2 , IniRead($INIFilePath, "Destination","Exclude Audio/Video","1"))
GUICtrlSetData($Input2 , IniRead($INIFilePath, "Destination","Other Backup Source",""))
GUICtrlSetData($Input1 , $Destination)
EndFunc

Func _ProcessPendingCopy($IfContinuePendingCopy,$ifCopyFiles)
    if _CheckDestinationFreeSpace() Then

         _Desktop($IfContinuePendingCopy,$ifCopyFiles)
         _Favorites($IfContinuePendingCopy,$ifCopyFiles)
         _Firefox($IfContinuePendingCopy,$ifCopyFiles)
         _BackupSelection($IfContinuePendingCopy,$ifCopyFiles)
         _MyDocuments($IfContinuePendingCopy,$ifCopyFiles)
         Sleep(2000)
         GUICtrlSetData($Edit1, " ")
         GUICtrlSetData($Edit1, "Backup Completed")
         if $ifCopyFiles then
            Local $SourceSize = DirGetSize (@DesktopDir)




            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; Must Always Be Last
                _Compress()

            EndIf

            if $Flashballoon = False Then
                TrayTip("Backup Completed", "Your Backup is completed", 10)
            EndIf
         EndIf
     Else
        ;MsgBox($MB_SYSTEMMODAL, "You do not have enough space at destination, you atleast need " & $SourceTotalSize & " MB Space")
     EndIf
EndFunc   ;==>_ProcessPendingCopy

Func _ProcessForm()
    If $Flashballoon = False Then
        TrayTip("Backup Completed", "Your Backup is completed", 10)
    EndIf

    While 1
        $nMsg = GUIGetMsg()
                If GUICtrlRead($Checkbox3) = $GUI_CHECKED  and  $HelpFlag = 1 Then ; Must Always Be Last
                    GUICtrlSetState($Checkbox3,$GUI_DISABLE)

                    $HelpFlag = 2

                    _OpenHelp()

                EndIf
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                _Exitcode()
            Case $Exit
                _Exitcode()
            Case $Button1
                _BackupDestination()
            Case $Button2
                _IncludeBackup()
            Case $BACKUP
                IniWrite($INIFilePath, "Destination", "Path", $Destination)
                IniWrite($INIFilePath, "Destination","Exclude Audio/Video",  GUICtrlRead($Checkbox2))
                IniWrite($INIFilePath, "Destination","Other Backup Source",  GUICtrlRead($Input2))


                ;iniread ($INIFilePath, "Source", "Path"
                If _Trim($Destination) = "" Then
                    GUICtrlSetData($Edit1, " ")
                    GUICtrlSetData($Edit1, "Destination path is not selected...Please select valid Destination path" & @CRLF, 1)
                    $Flag = False

                Else
                    ;_MyDocuments(False)
                    ;_Firefox(False)
                    ;_Desktop(False)
                    ;_Favorites(False)
                    ;_MsOutlook()
                    ;_BackupSelection(False)
                    _ProcessPendingCopy(False,False)
                    _ProcessPendingCopy(False,True)



                    _EnableControls()


                EndIf

        EndSwitch
    WEnd

EndFunc   ;==>_ProcessForm

Func _OpenHelp()
;~  Local $oWord = _Word_Create()
;~  Local $sDocument = @ScriptDir & "\Help.docx"
ShellExecute("hh.exe", @TempDir & "\Help.chm")
;~  _Word_DocOpen($oWord, $sDocument, Default, Default, True)
;GUISetHelp('hh.exe "' & @ScriptDir & '\Help.chm"')

    ;GUISetState(@SW_SHOW) ; will display an empty dialog box
EndFunc
Func _Exitcode()
    GUIDelete()
    Exit
EndFunc   ;==>_Exitcode

Func _Trim($LocalString)
    Return StringStripWS($LocalString, $STR_STRIPLEADING + $STR_STRIPTRAILING)
EndFunc   ;==>_Trim

Func _DisableControls()
    GUICtrlSetState($BACKUP, $GUI_DISABLE)
EndFunc   ;==>_DisableControls



Func _EnableControls()
    GUICtrlSetState($BACKUP, $GUI_ENABLE)
EndFunc   ;==>_EnableControls


Func _BackupDestination()
    $Destination = FileSelectFolder("Select backup destination", "", 7)
    if @error then Return ; #### Added in case user cancels #####
    GUICtrlSetData($Input1, $Destination)
    If DriveGetType($Destination) = "Removable" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is External one." & @CRLF & " This is against AON policy to copy data to external drives," & @CRLF & " tool will not be held responsible for not adhering AON policies" & @CRLF, 1)
    ElseIf DriveGetType($Destination) = "Network" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is on Network." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    Else
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is Local." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    EndIf

EndFunc   ;==>_BackupDestination



Func _IncludeBackup()
    $Includebackup = FileSelectFolder("Select folders to backup", "", 7)
    GUICtrlSetData($Input2, $Includebackup)
EndFunc   ;==>_IncludeBackup

Func _BackupSelection($CopyPending,$pCopyFiles)
    Local $aFileList = _FileListToArrayRec(GUICtrlRead($Input2), "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    _FileWriteLog(".\Backup.log", $Includebackup & " ..............Started ")
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, "Backing Up other selected folders" & @CRLF, 1)
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Other Backup", GUICtrlRead($Input2),$pCopyFiles)
    ;MsgBox(0,"","Done in " & TimerDiff($timer)/1000 & " seconds!")
    _FileWriteLog(".\Backup.log", GUICtrlRead($Input2) & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Manual selected backup Complete" & @CRLF, 1)
EndFunc   ;==>_BackupSelection

Func GetSourceFiles($SourceDir)
    Local $strPos = StringInStr(StringReverse($SourceDir), "\")
    Return StringMid($SourceDir, StringLen($SourceDir) - $strPos + 2, $strPos + 1)
EndFunc   ;==>GetSourceFiles


Func GetFileExtention($FileName)
    Local $strPos = StringInStr(StringReverse($FileName), ".")
    Return StringMid($FileName, StringLen($FileName) - $strPos + 1, $strPos)
EndFunc   ;==>GetSourceFiles

Func _MyDocuments($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@MyDocumentsDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    $1 = _ArraySearch($aFileList, "RECYCLER")
    _ArrayDelete($aFileList, $1)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    $2 = _ArraySearch($aFileList, "System Volume Information")
    _ArrayDelete($aFileList, $2)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users My Documents" & @CRLF, 1)
;~  DirCreate($Destination & "\MyDocuments")
    ;Call (_Copy("MyDocument"))
    ;_ArrayDisplay($aFileList, "MYDocuments")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "MyDocuments", @MyDocumentsDir,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> MyDocuments Backup Complete" & @CRLF, 1)
    $Flashballoon = False
EndFunc   ;==>_MyDocuments

Func _Favorites($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@UserProfileDir & "\Favorites", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)

    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users IE Favorites" & @CRLF, 1)
;~  DirCreate($Destination & "\Favorites")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Favorites", @UserProfileDir & "\Favorites",$pCopyFiles)
;~  MsgBox($MB_SYSTEMMODAL, "Title", $aFileList)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Favorites backup Complete" & @CRLF, 1)
EndFunc   ;==>_Favorites

Func _Desktop($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Started ")
;~  Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; #### CHANGED ####
    ; just find files (unless you want empty dirs copied?) and return the full path to the files
    Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1)
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Desktop", @DesktopDir,$pCopyFiles) ; #### send the source dir as a parameter for replacing on file copy ####

    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Desktop backup Complete" & @CRLF, 1)
EndFunc   ;==>_Desktop


Func _ProcessCurrentFolderCopy($ifCopyPending, $arrFileListToCopy, $currentFolderName, $s_SourceDir,$CopyFiles)

    If $ifCopyPending Then
        $arrFileListToCopy = IniReadSection($INIFilePath, $currentFolderName) ;read the files into a 2D array
        ;_ArrayDisplay($arrFileListToCopy, "1")
        ; delete the column that doesn't have the files in it (I think it's 1)
        _ArrayColDelete($arrFileListToCopy, 1, True) ; convert the array to a 1D
        ;_ArrayDisplay($arrFileListToCopy, "Array display")
        ;MsgBox($MB_ICONERROR, 'Copy', $arrFileListToCopy)
         _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
    Else
        if $CopyFiles then
             _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
        Else
             _UpdateIniFile($currentFolderName, $arrFileListToCopy)
        EndIf
    EndIf
;~  _ArrayDisplay($arrFileListToCopy, "Sorted tree")
    ;DirCopy(@DesktopDir, $Destination & "\Desktop", 1)
;~     Call (_Copy($currentFolderName,$arrFileListToCopy,$currentFolderName)) #### CHANGED ####

    if @error then MsgBox($MB_ICONERROR, 'Errors', 'Errors occured copying the files')

EndFunc   ;==>_ProcessCurrentFolderCopy

Func _Compress()
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Started ")
    Local $7zip = $Destination & "\7zip"
    DirCreate($7zip)
    FileInstall("tools\7za.exe", $7zip & "\7za.exe", 1)
    FileInstall("tools\7zCon.sfx", $7zip & "\7zCon.sfx", 1)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Compressing Backup" & @CRLF, 1)
    RunWait($7zip & "\7za a -r -y -sfx7zCon.sfx " & $Destination & "\Backup.exe " & $Destination & "\*.* ", "", @SW_HIDE)
    DirRemove($7zip, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Compress Data backup Complete" & @CRLF, 1)
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Completed ")
    $Flashballoon = True
EndFunc   ;==>_Compress

Func _Firefox($CopyPending,$pCopyFiles)
    _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Started  ")
    Local $aFileList = _FileListToArrayRec(@AppDataDir & "\Mozilla", "*", $FLTAR_FILES,$FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    ;_ArrayDisplay($aFileList, "Full array")
        GUICtrlSetData($Edit1, @CRLF, 1)
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "Backing Up Firefox Profile" & @CRLF, 1)
        If ProcessExists("firefox.exe") Then
            ProcessClose("firefox.exe")
        EndIf

        _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Firefox", @AppDataDir & "\Mozilla",$pCopyFiles)
        _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Completed ")
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "---> Firefox backup Complete" & @CRLF, 1)

    $Flashballoon = True
EndFunc   ;==>_Firefox

Func _Copy($s_SectionName, $as_FileList, $s_SourceDir)
    Local $i_Errors = 0 ; Set an error counter for file copy errors
    Local $s_Destination = GUICtrlRead($Input1) & '\' & $s_SectionName ; get the user selected destination and add the user folder
    ;_ArrayDisplay($as_FileList, "Full array")
    For $i = 1 To Ubound($as_FileList) -1
       ;MsgBox($MB_ICONERROR, 'Delete', $as_FileList[$i])
        if StringInStr(".mp3.mp4.vob.mpeg", GetFileExtention($as_FileList[$i])) = 0 OR GUICtrlRead($Checkbox2) <> $GUI_CHECKED then
            If Not FileCopy($as_FileList[$i], StringReplace(StringReplace($as_FileList[$i],"~eq~","="), $s_SourceDir, $s_Destination), $FC_OVERWRITE + $FC_CREATEPATH) Then
             $i_Errors += 1
            Else
                ; if you only delete the files successfully copied, you then have a record of those that weren't
                ; and could do something with that
                ;MsgBox($MB_ICONERROR, 'Delete1', StringReplace($as_FileList[$i],"~eq~","="))
                IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))
            EndIf
            Else
            ;MsgBox($MB_ICONERROR, 'Delete2', StringReplace($as_FileList[$i],"~eq~","="))
            IniDelete($INIFilePath, $s_SectionName, StringReplace($as_FileList[$i],"=","~eq~"))

        endif
    Next

    ; when the function returns you can check for @error it will tell you how many files failed to copy
    Return SetError($i_Errors)
EndFunc   ;==>_Copy


Func _UpdateIniFile($SectionName, $FileList)
    Local $CurrFileCopy

    $CurrFileCopy = IniReadSectionNames($INIFilePath)

    IniDelete($INIFilePath, $SectionName)
    For $FileCount = 1 To UBound($FileList) - 1
        IniWrite($INIFilePath, $SectionName, StringReplace($FileList[$FileCount],"=","~eq~"), $FileCount)
    Next
    FileClose($INIFilePath)

EndFunc   ;==>_UpdateIniFile


Func _CheckPendingCopy()
    Local $IsCopyPending = False
    ; Check if any key exists in any section of ini File
    $PendingKeyList = IniReadSectionNames($INIFilePath)

    If UBound($PendingKeyList) > 0 Then
        For $CurrSection In $PendingKeyList
            ; MsgBox($MB_SYSTEMMODAL, "Title", $CurrSection)
            If UBound(IniReadSection($INIFilePath, $CurrSection)) > 0 And $CurrSection <> "Destination" Then
                $IsCopyPending = True
                ExitLoop
            EndIf
        Next
    EndIf
    Return $IsCopyPending
EndFunc   ;==>_CheckPendingCopy

 

Link to comment
Share on other sites

The problem is with the iniread function to get the file list. There is a 32kb read limit with these functions so only the first 32kb per section are read to the array, this means not all files get copied. If you keep opening and closing the program it will eventually copy all the files. You need to look at this from SmOke_N

I mentioned in a previous post that using ini's was a bad idea for this type of function becuase of this limit. You may be able to workaround it with the IniRead_Ex functions.

For the zipping part, you could try using a list file as mentioned here and just include all the files you get from different the FileReadToArray calls. It should skip the need to copy the files to a temp dir then compress.

Link to comment
Share on other sites

Hi Benners,

So if i go through script which you altered wherein no ini is being used...script does not work as expected. Expectation is to gather information of all files to be copied as if it gets interrupted in between then we can carry on with that point or continue from start.

Below is your script :

# ;NoTrayIcon
;MsgBox($MB_SYSTEMMODAL, "Title", $test)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Backup.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3> ; #### ADDED ####
#include <GuiEdit.au3>
#include <Array.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
;#include <IniToArray.au3>

Global $sInfo
Global $Destination
Global $Includebackup
Global $Flashballoon = True
Local $timer = TimerInit()
Global $Currfile
Global $Arrfile
Global $INIFilePath = @ScriptDir & "\CurrentDir.ini"


$Form1_1 = GUICreate("Backup", 627, 384)
$Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Input1 = GUICtrlCreateInput("", 184, 11, 353, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Edit1 = GUICtrlCreateEdit("", 4, 160, 613, 185)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
$BACKUP = GUICtrlCreateButton("Backup", 454, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Exit = GUICtrlCreateButton("Exit", 536, 352, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 16, 356, 157, 17)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetTip(-1, "Use to compress data")
$Input2 = GUICtrlCreateInput("", 184, 48, 353, 21)
$Button2 = GUICtrlCreateButton("Browse", 540, 48, 75, 25)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label2 = GUICtrlCreateLabel("Include More :", 14, 51, 130, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Label3 = GUICtrlCreateLabel("Select to include Outlook mailbox and lync chat :", 16, 91, 445, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
$Checkbox2 = GUICtrlCreateCheckbox("Outlook Mailbox and chat", 16, 128, 185, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Lucida Console")
GUISetState(@SW_SHOW)

If _CheckPendingCopy() = True Then
    ;GuiCtrlSetData($Edit1, " ")
    ;GuiCtrlSetData($Edit1, "Previous copy seems pending or was interupted " & @CRLF & "Do you want to Continue with previous copy or start copy again from begining")

    Local $CopyData = MsgBox($MB_YESNOCANCEL, "Alert", "Previous copy seems pending or was interupted " & @CRLF & "Press YES to continue with previous copy or NO to start from Beginining")
    $Destination = IniRead($INIFilePath, "Destination", "Path", "")
    If $CopyData = 6 Then
        _ProcessPendingCopy(True)
    ElseIf $CopyData = 7 Then
        _ProcessPendingCopy(False)
    EndIf
EndIf
_ProcessForm()

Func _ProcessPendingCopy($IfContinuePendingCopy)
    _Desktop($IfContinuePendingCopy)
    _Favorites($IfContinuePendingCopy)
    _Firefox($IfContinuePendingCopy)
    _MyDocuments($IfContinuePendingCopy)

EndFunc   ;==>_ProcessPendingCopy

Func _ProcessForm()
    If $Flashballoon = False Then
        TrayTip("Backup Completed", "Your Backup is completed", 10)
    EndIf

    While 1
        $nMsg = GUIGetMsg()

        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                _Exitcode()
            Case $Exit
                _Exitcode()
            Case $Button1
                _BackupDestination()
            Case $Button2
                _IncludeBackup()
            Case $BACKUP
                IniWrite($INIFilePath, "Destination", "Path", $Destination)
                If _Trim($Destination) = "" Then
                    GUICtrlSetData($Edit1, " ")
                    GUICtrlSetData($Edit1, "Destination path is not selected...Please select valid Destination path" & @CRLF, 1)
                    $Flag = False

                Else
;~                  _MyDocuments(False)
                    ;_Firefox(False)
                    _Desktop(False)
                    _Favorites(False)

                    ;_MsOutlook()
                    ;_BackupSelection()


                    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; Must Always Be Last
                        _Compress()
                    EndIf

                    If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then ; Must Always Be Last
                        _MsOutlook()
                    EndIf
                    _EnableControls()
                    If $Flashballoon = False Then
                        TrayTip("Backup Completed", "Your Backup is completed", 10)
                    EndIf
                EndIf
        EndSwitch
    WEnd

EndFunc   ;==>_ProcessForm


Func _Exitcode()
    GUIDelete()
    Exit
EndFunc   ;==>_Exitcode

Func _Trim($LocalString)
    Return StringStripWS($LocalString, $STR_STRIPLEADING + $STR_STRIPTRAILING)
EndFunc   ;==>_Trim

Func _DisableControls()
    GUICtrlSetState($BACKUP, $GUI_DISABLE)
EndFunc   ;==>_DisableControls



Func _EnableControls()
    GUICtrlSetState($BACKUP, $GUI_ENABLE)
EndFunc   ;==>_EnableControls


Func _BackupDestination()
    $Destination = FileSelectFolder("Select backup destination", "", 7)
    if @error then Return ; #### Added in case user cancels #####
    GUICtrlSetData($Input1, $Destination)
    If DriveGetType($Destination) = "Removable" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is External one." & @CRLF & " This is against AON policy to copy data to external drives," & @CRLF & " tool will not be held responsible for not adhering AON policies" & @CRLF, 1)
    ElseIf DriveGetType($Destination) = "Network" Then
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is on Network." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    Else
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "The Drive you selected is Local." & @CRLF & "Please make sure you have plenty of space before proceeding with Backup")
    EndIf

EndFunc   ;==>_BackupDestination



Func _IncludeBackup()
    $Includebackup = FileSelectFolder("Select folders to backup", "", 7)
    GUICtrlSetData($Input2, $Includebackup)
EndFunc   ;==>_IncludeBackup

Func _BackupSelection()
    _FileWriteLog(".\Backup.log", $Includebackup & " ..............Started ")
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, "Backing Up other selected folders" & @CRLF, 1)
    DirCreate($Destination & "\Manual Selected Folders")
    RunWait(@ComSpec & ' /k robocopy.exe "' & $Includebackup & '" "' & $Destination & "\Manual Selected Folders\" & GetSourceFiles($Includebackup) & '" /S /E /R:0 /W:0', "", @SW_HIDE)
    ;MsgBox(0,"","Done in " & TimerDiff($timer)/1000 & " seconds!")
    _FileWriteLog(".\Backup.log", $Includebackup & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Manual selected backup Complete" & @CRLF, 1)
EndFunc   ;==>_BackupSelection

Func GetSourceFiles($SourceDir)
    Local $strPos = StringInStr(StringReverse($SourceDir), "\")
    Return StringMid($SourceDir, StringLen($SourceDir) - $strPos + 2, $strPos + 1)
EndFunc   ;==>GetSourceFiles

Func _MyDocuments($CopyPending)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@MyDocumentsDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    $1 = _ArraySearch($aFileList, "RECYCLER")
    _ArrayDelete($aFileList, $1)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    $2 = _ArraySearch($aFileList, "System Volume Information")
    _ArrayDelete($aFileList, $2)
    $Num = $aFileList[0]
    $aFileList[0] = $Num - 1
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users My Documents" & @CRLF, 1)
;~  DirCreate($Destination & "\MyDocuments")
    ;Call (_Copy("MyDocument"))
    _ArrayDisplay($aFileList, "MYDocuments")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "MyDocuments", @MyDocumentsDir)
    _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> MyDocuments Backup Complete" & @CRLF, 1)
EndFunc   ;==>_MyDocuments

Func _Favorites($CopyPending)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Started ")
    Local $aFileList = _FileListToArrayRec(@UserProfileDir & "\Favorites", "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)

    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users IE Favorites" & @CRLF, 1)
;~  DirCreate($Destination & "\Favorites")
    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Favorites", @UserProfileDir & "\Favorites")
;~  MsgBox($MB_SYSTEMMODAL, "Title", $aFileList)
    _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Favorites backup Complete" & @CRLF, 1)
EndFunc   ;==>_Favorites

Func _Desktop($CopyPending)
    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Started ")
;~  Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; #### CHANGED ####
    ; just find files (unless you want empty dirs copied?) and return the full path to the files
    Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1)
;~  DirCreate($Destination & "\Desktop") ; #### REMOVED #### no need to create

    ;_ArrayDisplay($aFileList, "Sorted tree")

    ;if $CopyPending = False then Call (_UpdateIniFile("Desktop",$aFileList))

    ;if $CopyPending then $aFileList = IniReadSection($INIfilePath,"Desktop")

    _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Desktop", @DesktopDir) ; #### send the source dir as a parameter for replacing on file copy ####

    _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Completed ")
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Desktop backup Complete" & @CRLF, 1)
EndFunc   ;==>_Desktop


Func _ProcessCurrentFolderCopy($ifCopyPending, $arrFileListToCopy, $currentFolderName, $s_SourceDir)

    If $ifCopyPending Then
        $arrFileListToCopy = IniReadSection($INIFilePath, $currentFolderName) ;read the files into a 2D array
        ;_ArrayDisplay($arrFileListToCopy, "1")
        ; delete the column that doesn't have the files in it (I think it's 1)
        _ArrayColDelete($arrFileListToCopy, 1, True) ; convert the array to a 1D
    Else
        _UpdateIniFile($currentFolderName, $arrFileListToCopy)
    EndIf
;~  _ArrayDisplay($arrFileListToCopy, "Sorted tree")
    ;DirCopy(@DesktopDir, $Destination & "\Desktop", 1)
;~     Call (_Copy($currentFolderName,$arrFileListToCopy,$currentFolderName)) #### CHANGED ####
    _Copy($currentFolderName, $arrFileListToCopy, $s_SourceDir) ; no need to add $currentFolderName twice
    if @error then MsgBox($MB_ICONERROR, 'Errors', 'Errors occured copying the files')
EndFunc   ;==>_ProcessCurrentFolderCopy

Func _OstFileExits()
    ; List all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray(@UserProfileDir & "\AppData\Local\Microsoft\Outlook", "*.ost")
    Local $FileExists = False
    If @error = 1 Then
        GUICtrlSetData($Edit1, "---> Outlook file path is invalid." & @CRLF, 1)
    ElseIf @error = 4 Then
        GUICtrlSetData($Edit1, "---> Cannot Find .ost file in Outlook profile default path...Please manually choose .ost file to backup" & @CRLF, 1)
    Else
        If $aFileList[0] > 0 Then $FileExists = True
        $FileExits = True
    EndIf

    ; Display the results returned by _FileListToArray.
    ;_ArrayDisplay($aFileList, "$aFileList")
    Return $FileExists

EndFunc   ;==>_OstFileExits

Func _MsOutlook()
    Local $Outlook = @UserProfileDir & "\AppData\Local\Microsoft\Outlook"
    If _OstFileExits() Then
        If ProcessExists("Outlook.exe") Then ; Check if the Notepad process is running.
            GUICtrlSetData($Edit1, " ")
            GUICtrlSetData($Edit1, "Outlook is still running, will be closed within 10 seconds." & @CRLF, 1)
            Sleep(10000)
            Run(@ComSpec & " /c taskkill /F /PID " & "Outlook.exe" & " /T", @SystemDir, @SW_HIDE)
            ProcessClose("Outlook.exe")


        EndIf

        If ProcessExists("ucmapi.exe") Then ; Check if the Notepad process is running.
            GUICtrlSetData($Edit1, " ")
            GUICtrlSetData($Edit1, "ucmapi is still running, will be closed " & @CRLF, 1)
            Sleep(1000)
            Run(@ComSpec & " /c taskkill /F /PID " & "ucmapi.exe" & " /T", @SystemDir, @SW_HIDE)
            ProcessClose("ucmapi.exe")

        EndIf

        If ProcessExists("Lync.exe") Then ; Check if the Notepad process is running.
            GUICtrlSetData($Edit1, " ")
            GUICtrlSetData($Edit1, "Lync is still running, will be closed within 10 seconds." & @CRLF, 1)
            Sleep(10000)
            Run(@ComSpec & " /c taskkill /F /PID " & "Lync.exe" & " /T", @SystemDir, @SW_HIDE)
            ProcessClose("Lync.exe")

        EndIf

        If ProcessExists("Communicator.exe") Then ; Check if the Notepad process is running.
            GUICtrlSetData($Edit1, " ")
            GUICtrlSetData($Edit1, "Lync is still running, will be closed within 10 seconds." & @CRLF, 1)
            Sleep(10000)
            Run(@ComSpec & " /c taskkill /F /PID " & "Communicator.exe" & " /T", @SystemDir, @SW_HIDE)
            ProcessClose("Communicator.exe")

        EndIf
        _FileWriteLog(".\Backup.log", @UserProfileDir & "\AppData\Local\Microsoft\Outlook" & " ..............Started @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC)
        GUICtrlSetData($Edit1, @CRLF, 1)
        GUICtrlSetData($Edit1, "Backing Up Current User's Microsoft Outlook Data" & @CRLF, 1)
        DirCreate($Destination & "\MSOutlook")
        MsgBox(0, "", "Done in " & $Destination & " seconds!")
        MsgBox(0, "", "Done in " & $Destination & "\MSOutlook" & " seconds!")
        ;RunWait(@ComSpec & ' /k robocopy.exe "' & $IncludeBackup & '" "' & $Destination & "\Manual Selected Folders\" & GetSourceFiles($IncludeBackup) & '" /S /E /R:0 /W:0', "", @SW_HIDE)
        ;@UserProfileDir & "\AppData\Local\Microsoft\Outlook"
        RunWait(@ComSpec & ' /k robocopy.exe "' & $Outlook & '" "' & $Destination & "\MSOutlook" & "*.ost" & '" & /MIR', "", @SW_SHOW)
        ;FileCopy($Outlook & "\*.ost", $Destination & "\Microsoft Outlook", 1)
        ;DirCopy($Outlook, $Destination & "\Microsoft Outlook", 1)

        While 1
            Sleep(10)
            If FileGetSize($Outlook & "\*.ost") = FileGetSize($Destination & "\Microsoft Outlook\*.ost") Then
                ExitLoop
            EndIf
        WEnd
        _FileWriteLog(".\Backup.log", @UserProfileDir & "\AppData\Local\Microsoft\Outlook" & " ..............Completed @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC)
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "---> Outlook backup Complete" & @CRLF, 1)
        $Flashballoon = False
    EndIf
EndFunc   ;==>_MsOutlook


Func _Compress()
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Started ")
    Local $7zip = $Destination & "\7zip"
    DirCreate($7zip)
    FileInstall("tools\7za.exe", $7zip & "\7za.exe", 1)
    FileInstall("tools\7zCon.sfx", $7zip & "\7zCon.sfx", 1)
    GUICtrlSetData($Edit1, @CRLF, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "Compressing Backup" & @CRLF, 1)
    RunWait($7zip & "\7za a -r -y -sfx7zCon.sfx " & $Destination & "\Backup.exe " & $Destination & "\*.* ", "", @SW_HIDE)
    DirRemove($7zip, 1)
    GUICtrlSetData($Edit1, " ")
    GUICtrlSetData($Edit1, "---> Compress Data backup Complete" & @CRLF, 1)
    _FileWriteLog(".\Backup.log", "Compression" & " ..............Completed ")
    $Flashballoon = True
EndFunc   ;==>_Compress

Func _Firefox($CopyPending)
    _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Started  ")
    Local $aFileList = @AppDataDir & "\Mozilla"
    If FileExists($aFileList) = 1 Then
        GUICtrlSetData($Edit1, @CRLF, 1)
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "Backing Up Firefox Profile" & @CRLF, 1)
        DirCreate($Destination & "\Firefox")
        If ProcessExists("firefox.exe") Then
            ProcessClose("firefox.exe")
        EndIf
        _ProcessCurrentFolderCopy($CopyPending, $aFileList, "Desktop", @AppDataDir & "\Mozilla")
        _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Completed ")
        GUICtrlSetData($Edit1, " ")
        GUICtrlSetData($Edit1, "---> Firefox backup Complete" & @CRLF, 1)
    EndIf
    $Flashballoon = True
EndFunc   ;==>_Firefox

Func _Copy($s_SectionName, $as_FileList, $s_SourceDir)
    Local $i_Errors = 0 ; Set an error counter for file copy errors
    Local $s_Destination = GUICtrlRead($Input1) & '\' & $s_SectionName ; get the user selected destination and add the user folder

    For $i = 1 To $as_FileList[0]
        If Not FileCopy($as_FileList[$i], StringReplace($as_FileList[$i], $s_SourceDir, $s_Destination), $FC_OVERWRITE + $FC_CREATEPATH) Then
            $i_Errors += 1
        Else
            ; if you only delete the files successfully copied, you then have a record of those that weren't
            ; and could do something with that
            IniDelete($INIFilePath, $s_SectionName, $as_FileList[$i])
        EndIf
    Next

    ; when the function returns you can check for @error it will tell you how many files failed to copy
    Return SetError($i_Errors)
EndFunc   ;==>_Copy

;~ Func _Copy($SectionName, $aFileList, $DestinationFolderToCopy)

;~      ; List all the files and folders in the desktop directory using the default parameters and return the full path.

;~      ;IniWrite($sFilePath, "General", "Title", $aFileList)
;~      ;_FileWriteFromArray($sFilePath, $aFileList, 1)
;~      ;_ArrayDisplay($aFileList, "$aFileList rrdrrrer")
;~       Local $tmpDestination=$Destination & "\" & $DestinationFolderToCopy
;~ ;MsgBox($MB_SYSTEMMODAL, "$tmpDestination", $tmpDestination)
;~    For $Fcount = 1 to (Ubound ($aFileList) - 1)
;~       if (StringInStr($aFileList[$Fcount],".") = 0) then
;~          ;if file extention is not available then it is new sub directory
;~         ; $tmpDestination=$Destination & $DestinationFolderToCopy & "\" & $aFileList[$Fcount]
;~          $test = DirGetSize($tmpDestination & "\" & $aFileList[$Fcount])
;~          ;MsgBox($MB_SYSTEMMODAL, "Title", $tmpDestination)
;~          ;check if new sub directory exists or not. if not then create
;~          if (DirGetSize($tmpDestination & "\" & $aFileList[$Fcount]) =-1) then
;~            DirCreate($tmpDestination & "\" & $aFileList[$Fcount])
;~          EndIf
;~       endIf
;~       MsgBox($MB_SYSTEMMODAL, "Title", $tmpDestination & "\" & $aFileList[$Fcount])
;~       FileCopy ($aFileList[$Fcount],   $tmpDestination & "\" & $aFileList[$Fcount])
;~       ;alert($aFileList[$Fcount)
;~       IniDelete ($INIfilePath, $SectionName, $aFileList[$Fcount])

;~    Next

;~ EndFunc

Func _UpdateIniFile($SectionName, $FileList)
;~  MsgBox($MB_SYSTEMMODAL, "$SectionName", $SectionName)
;~  MsgBox($MB_SYSTEMMODAL, "Ubound", UBound($FileList))
    ;_arrayToIni($FilePath, $SectionName, $FileList)

    ;_ArrayDisplay($FileList, "Sorted tree")

    IniDelete($INIFilePath, $SectionName)
    For $FileCount = 1 To UBound($FileList) - 1
        IniWrite($INIFilePath, $SectionName, $FileList[$FileCount], $FileCount)
    Next
    FileClose($INIFilePath)

EndFunc   ;==>_UpdateIniFile

Func _CheckPendingCopy()
    Local $IsCopyPending = False
    ; Check if any key exists in any section of ini File
    $PendingKeyList = IniReadSectionNames($INIFilePath)

    If UBound($PendingKeyList) > 0 Then
        For $CurrSection In $PendingKeyList
            ; MsgBox($MB_SYSTEMMODAL, "Title", $CurrSection)
            If UBound(IniReadSection($INIFilePath, $CurrSection)) > 0 And $CurrSection <> "Destination" Then
                $IsCopyPending = True
                ExitLoop
            EndIf
        Next
    EndIf
    Return $IsCopyPending
EndFunc   ;==>_CheckPendingCopy

 

Link to comment
Share on other sites

Apolozies this is the script your provided:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Backup.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#Region #### AutoIt Includes ####
#include <Array.au3>
#include <ColorConstants.au3>
#include <File.au3>
#include <GUIConstants.au3>
#include <String.au3>
#include <WinAPIFiles.au3>
#EndRegion #### AutoIt Includes ####

#Region ### Globals ####
; set the constant values for the array elements
Global Enum _
        $e_MAINGUI, _
        $e_BACKUPDESTINATIONLBL, _
        $e_INCLUDEMORELBL, _
        $e_EXCLUDEAVTYPECHK, _
        $e_EDITBOX, _
        $e_COMPRESSBACKUPCHK, _
        $e_BACKUPBTN, _
        $e_ARRAYMAX

; create a global array for the controls
Global $aid_Controls[$e_ARRAYMAX]
Global $bln_FlashBalloon = True
#EndRegion ### Globals ####

GUI_Draw() ; draw the gui

; check for interrupted copy
If Backup_CheckForPending() Then Backup_CopyFiles(True)

While 1
    Sleep(10)
WEnd

Func Backup_Run()
    Backup_CopyFiles()
EndFunc   ;==>Backup_Run

Func Backup_CopyFiles($bln_ResumeCopy = False)
    Local $as_Folders = 0

    If $bln_ResumeCopy Then
        $as_Folders = IniReadSection(INI_ReturnFilePath(), 'Pending')
    Else
        $as_Folders = Backup_GetFolderArray() ; get an array of the selected folders
    EndIf

    If Not IsArray($as_Folders) Then Return SetError(1)

    GUICtrlSetData($aid_Controls[$e_EDITBOX], '') ; clear the edit box

    Local $s_Info = '' ; string for edit box updating
    Local $s_Mask = '*' ; initial mask for FLTAR search
    Local $s_Source = '', $s_Destination = '', $s_DestinationFile = '', $s_Folder = ''
    Local $as_FLTAR = 0 ; array for files
    Local $i_CopyErrors = 0 ; error counter

    ; update the mask to exclude video files
    If GUICtrlRead($aid_Controls[$e_EXCLUDEAVTYPECHK]) = $GUI_CHECKED Then $s_Mask = '*|*.mp3;*.mp4;*.vob;*.mpeg|'

    ; loop through the selected folders
    For $i = 1 To $as_Folders[0][0]
        $i_CopyErrors = 0 ; reset the error counter
        $s_Folder = $as_Folders[$i][0] ; update folder name

        If $bln_ResumeCopy Then
            $s_Source = StringRegExpReplace($as_Folders[$i][1], '\|.*$', '') ; get the source directory
            $s_Destination = StringRegExpReplace($as_Folders[$i][1], '^.*\|', '') ; get the destination directory
        Else
            $s_Source = $as_Folders[$i][1] ; update the source
            $s_Destination = GUICtrlRead($aid_Controls[$e_BACKUPDESTINATIONLBL]) & '\' & $s_Folder ; update the destination
        EndIf

        If Not $bln_ResumeCopy Then
            ; write the ini info (used to check for failed copy operations)
            IniWrite(INI_ReturnFilePath(), _ ; inifile
                    'Pending', _ ; section
                    $s_Folder, _ ; key (folder)
                    $s_Source & '|' & _ ; value (source & '|'
                    $s_Destination) ; destinarion)
        EndIf

        _FileWriteLog(Log_ReturnFilePath(), $s_Source & ' ..............Started ')

        ; update the edit box
        GUICtrlSetData($aid_Controls[$e_EDITBOX], @CRLF & 'Backing Up ' & $s_Folder & ' Folder' & @CRLF, ' ')

        ; get a list of files and folders in the specified folder
        $as_FLTAR = _FileListToArrayRec($s_Source, $s_Mask, $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
        If @error Then ContinueLoop ; #### will need changing to delete ini section if no files found ####

        #Region copy files and folder ####
        ; loop through the files\folders
        For $j = 1 To $as_FLTAR[0]
            ; replace the source path with the destination path
            $s_DestinationFile = StringReplace($as_FLTAR[$j], $s_Source, $s_Destination)

            ; check if path is a directory
            If _WinAPI_PathIsDirectory($as_FLTAR[$j]) Then
                ; check if the directory is empty
                If _WinAPI_PathIsDirectoryEmpty($as_FLTAR[$j]) Then
                    ; if we're resuming a copy but the file folder skip it
                    If $bln_ResumeCopy And FileExists($s_DestinationFile) Then ContinueLoop

                    ; copy the directory
                    If Not DirCopy($as_FLTAR[$j], _ ; source
                            $s_DestinationFile, _ ; destination
                            $FC_OVERWRITE) _ ; overwrite existing files
                            Then $i_CopyErrors += 1 ; increase the copy error count

                EndIf
            Else ; path is a file
                ; if we're resuming a copy but the file exists skip it
                If $bln_ResumeCopy And FileExists($s_DestinationFile) Then ContinueLoop

                If Not FileCopy($as_FLTAR[$j], _ ; source
                        $s_DestinationFile, _ ; destination
                        $FC_OVERWRITE + $FC_CREATEPATH) _ ; overwite existing and create directory structure
                        Then $i_CopyErrors += 1 ; increase the copy error count

            EndIf
        Next
        #EndRegion copy files and folder ####

        ; delete the copied folder entry
        If Not $i_CopyErrors Then
            IniDelete(INI_ReturnFilePath(), 'Pending', $s_Folder)
            $s_Info = $s_Folder & ' backup Complete'
        Else
            $s_Info = $s_Folder & ' backup failed'
        EndIf

        _FileWriteLog(Log_ReturnFilePath(), $s_Source & ' ..............Completed ')

        ; update the edit box
        GUICtrlSetData($aid_Controls[$e_EDITBOX], '', ' ')
        GUICtrlSetData($aid_Controls[$e_EDITBOX], '---> ' & $s_Info & @CRLF, ' ')

        Sleep(10)
    Next

    ; update the edit box
    GUICtrlSetData($aid_Controls[$e_EDITBOX], @CRLF, ' ')
    GUICtrlSetData($aid_Controls[$e_EDITBOX], '#### All Folder backup jobs completed ####' & @CRLF, ' ')
EndFunc   ;==>Backup_CopyFiles

Func Backup_CheckForPending()
    ; read the pending section
    Local $as_IRS = IniReadSection(INI_ReturnFilePath(), 'Pending')
    If @error Then Return False

    ; pending copy operation so get user action
    If MsgBox(BitOR($MB_ICONQUESTION, $MB_YESNO), 'Alert', 'A previous copy seems pending or was interupted ' & @CRLF & 'Select Yes to resume copying, No to skip') = $IDYES Then
        Return True
    Else
        IniDelete(INI_ReturnFilePath(), 'Pending')
        Return False
    EndIf
EndFunc   ;==>Backup_CheckForPending

Func Backup_GetFolderArray()
    Local $i_Folders = 4 ; set the number of folders in the array

    ; create a 2D array with the default folders info
    Local $as_Folders[$i_Folders + 1][2] = _
            [[$i_Folders, ''], _
            ['Desktop', Desktop_ReturnFolderPath()], _
            ['Favorites', Favorites_ReturnFolderPath()], _
            ['Firefox', Firefox_ReturnFolderPath()], _
            ['MyDocuments', MyDocuments_ReturnFolderPath()]]

    ; get the extra folders from the label
    If GUICtrlRead($aid_Controls[$e_INCLUDEMORELBL]) Then ; extra folders to copy
        Local $as_MoreFolders = StringSplit(GUICtrlRead($aid_Controls[$e_INCLUDEMORELBL]), '|') ; split the folders

        ; calculate the new number of folders
        Local $i_FolderCount = $i_Folders + $as_MoreFolders[0]

        ; resize the array to accept the new folders
        ReDim $as_Folders[$i_FolderCount + 1][2]

        ; update the folder count
        $as_Folders[0][0] = $i_FolderCount

        ; loop through the new folder list and add the info to the array
        For $i = 1 To $as_MoreFolders[0]
            $as_Folders[$i_Folders + $i][0] = _StringTitleCase(StringRegExpReplace($as_MoreFolders[$i], "^.*\\|\..*$", "")) ; get the last folder name from the source
            $as_Folders[$i_Folders + $i][1] = $as_MoreFolders[$i] ; source folders
        Next
    EndIf

    Return $as_Folders
EndFunc   ;==>Backup_GetFolderArray

Func Folder_BrowseForDestination()
    Local $s_Destination = FileSelectFolder('Select backup destination', '', $FSF_CREATEBUTTON + $FSF_NEWDIALOG + $FSF_EDITCONTROL)

    If @error Then ; user cancelled
        ; disable the backup button if no destination is selected
        If GUICtrlRead($aid_Controls[$e_BACKUPDESTINATIONLBL]) = '' Then GUICtrlSetState($aid_Controls[$e_BACKUPBTN], $GUI_DISABLE)
        Return
    EndIf

    ; enable the backup button
    GUICtrlSetState($aid_Controls[$e_BACKUPBTN], $GUI_ENABLE)

    ; update the label
    GUICtrlSetData($aid_Controls[$e_BACKUPDESTINATIONLBL], $s_Destination)

    ; get the type of destination drive selected
    Local $s_DrvType = DriveGetType($s_Destination)

    ; set a default message for the edit box
    Local $s_Message = 'The Drive you selected is Local.' & @CRLF & _
            'Please make sure you have plenty of space before proceeding with Backup'

    ; change message based on drive selection
    If $s_DrvType = 'Removable' Then
        $s_Message = 'The Drive you selected is an External one.' & @CRLF & _
                ' This is against AON policy to copy data to external drives,' & @CRLF & _
                ' tool will not be held responsible for not adhering AON policies' & @CRLF
    ElseIf $s_DrvType = 'Network' Then
        $s_Message = 'The Drive you selected is on Network.' & @CRLF & _
                'Please make sure you have plenty of space before proceeding with Backup'
    EndIf

    ; update the edit control
    GUICtrlSetData($aid_Controls[$e_EDITBOX], ' ')
    GUICtrlSetData($aid_Controls[$e_EDITBOX], $s_Message, 1)
EndFunc   ;==>Folder_BrowseForDestination

Func Folder_BrowseForMore()
    ; read the old selection from the label
    Local $s_OldSelection = GUICtrlRead($aid_Controls[$e_INCLUDEMORELBL])

    ; get any new selections from the user
    Local $s_Selection = FileSelectFolder('Select folders to backup', '', $FSF_CREATEBUTTON + $FSF_NEWDIALOG + $FSF_EDITCONTROL)
    If @error Then Return

    ; combine the old and new selections
    $s_Selection = $s_OldSelection & '|' & $s_Selection

    ; trim any leading pipe symbols from the string and update the label
    GUICtrlSetData($aid_Controls[$e_INCLUDEMORELBL], StringRegExpReplace($s_Selection, '\A[\|]+', ''))
EndFunc   ;==>Folder_BrowseForMore

Func GUI_Draw()
    Opt('GUIOnEventMode', 1)

    $aid_Controls[$e_MAINGUI] = GUICreate('Backup', 627, 384)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'Program_Exit')

    ; set the font properties for the text
    Local $i_FontSize = 11
    Local $i_FontWeight = 400
    Local $s_FontName = 'Lucida Console'

    #Region #### Backup controls ####
    GUICtrlCreateLabel('Backup Destination:', 4, 12, 175, 19, BitOR($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)

    $aid_Controls[$e_BACKUPDESTINATIONLBL] = GUICtrlCreateLabel('', 175, 11, 353, 21, BitOR($SS_SUNKEN, $DT_END_ELLIPSIS), $WS_EX_STATICEDGE)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetBkColor(-1, $COLOR_WHITE)

    GUICtrlCreateButton('Browse', 540, 10, 75, 25)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, 0, $s_FontName)
    GUICtrlSetOnEvent(-1, 'Folder_BrowseForDestination')
    #EndRegion #### Backup controls ####

    #Region #### Include More controls ####
    GUICtrlCreateLabel('Include More :', 14, 51, 130, 19)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)

    $aid_Controls[$e_INCLUDEMORELBL] = GUICtrlCreateLabel('', 175, 48, 353, 21, BitOR($SS_SUNKEN, $DT_END_ELLIPSIS), $WS_EX_STATICEDGE)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetBkColor(-1, $COLOR_WHITE)

    GUICtrlCreateButton('Browse', 540, 48, 75, 25)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetOnEvent(-1, 'Folder_BrowseForMore')
    #EndRegion #### Include More controls ####

    $aid_Controls[$e_EXCLUDEAVTYPECHK] = GUICtrlCreateCheckbox('Exclude Audio/Video file types', 16, 128, 445, 17)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetOnEvent(-1, 'ExcludeAV_Clicked')

    $aid_Controls[$e_EDITBOX] = GUICtrlCreateEdit('', 4, 160, 613, 185)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlSetBkColor(-1, $COLOR_BLACK)

    $aid_Controls[$e_BACKUPBTN] = GUICtrlCreateButton('Backup', 454, 352, 75, 25)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetOnEvent(-1, 'Backup_Run')

    GUICtrlCreateButton('Exit', 536, 352, 75, 25)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetOnEvent(-1, 'Program_Exit')

    $aid_Controls[$e_COMPRESSBACKUPCHK] = GUICtrlCreateCheckbox('Compress Backup', 16, 356, 157, 17)
    GUICtrlSetFont(-1, $i_FontSize, $i_FontWeight, $GUI_FONTNORMAL, $s_FontName)
    GUICtrlSetOnEvent(-1, 'CompressBackup_Clicked')
    GUICtrlSetTip(-1, 'Use to compress data')

    GUI_LoadOptions() ; load the control states

    GUISetState() ; show the main gui
EndFunc   ;==>GUI_Draw

Func GUI_LoadOptions()
    ; set the ExcludeAV checkbox state
    GUICtrlSetState($aid_Controls[$e_EXCLUDEAVTYPECHK], Number(IniRead(INI_ReturnFilePath(), 'Options', 'ExcludeAV', $GUI_UNCHECKED)))
    GUICtrlSetState($aid_Controls[$e_COMPRESSBACKUPCHK], Number(IniRead(INI_ReturnFilePath(), 'Options', 'CompressBackup', $GUI_UNCHECKED)))
EndFunc   ;==>GUI_LoadOptions

Func Program_Exit()
    GUIDelete()
    Exit
EndFunc   ;==>Program_Exit

#Region #### Checkbox Functions ####
Func ExcludeAV_Clicked()
    ; update the ini with the checkbox state
    IniWrite(INI_ReturnFilePath(), 'Options', 'ExcludeAV', GUICtrlRead($aid_Controls[$e_EXCLUDEAVTYPECHK]))
EndFunc   ;==>ExcludeAV_Clicked

Func CompressBackup_Clicked()
    ; update the ini with the checkbox state
    IniWrite(INI_ReturnFilePath(), 'Options', 'CompressBackup', GUICtrlRead($aid_Controls[$e_COMPRESSBACKUPCHK]))
EndFunc   ;==>CompressBackup_Clicked

#EndRegion #### Checkbox Functions ####

#Region #### Return Path Functions ####
Func Desktop_ReturnFolderPath()
    Return @DesktopDir
EndFunc   ;==>Desktop_ReturnFolderPath

Func Favorites_ReturnFolderPath()
    Return @UserProfileDir & '\Favorites'
EndFunc   ;==>Favorites_ReturnFolderPath

Func Firefox_ReturnFolderPath()
    Return @AppDataDir & '\Mozilla'
EndFunc   ;==>Firefox_ReturnFolderPath

Func INI_ReturnFilePath()
    Return @ScriptDir & '\CurrentDir.ini'
EndFunc   ;==>INI_ReturnFilePath

Func Log_ReturnFilePath()
    Return '.\Backup.log'
EndFunc   ;==>Log_ReturnFilePath

Func MyDocuments_ReturnFolderPath()
    Return @MyDocumentsDir
EndFunc   ;==>MyDocuments_ReturnFolderPath
#EndRegion #### Return Path Functions ####

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...