hiteshluthraauto Posted April 18, 2017 Share Posted April 18, 2017 (edited) Hi Gentlemen, I m learning autoit and already have interest in it therefore wanted to create a BackupPC tool which can do following stuff 1) Automatically copy predefined User folders like desktop, My documents, favourites etc 2) Give user option to select one more path to include in backup 3) Option to backup .ost file 4) Option to zip backup 5) Last and the selling thing feature which is to continue copying where it left (due to any issue if interrupted)....that is the main feature where im getting stuck as code is giving some error which im not able to identify. There are three options when copying was interrupted , yes to continue where we left, NO to start from beginning and Cancel to select new backup source. NO option does work perfectly fine but there are issues when i click YES on prompt. Attaching full code here Error which im receiving is : Array variable has incorrect number of subscripts or subscript dimension range exceeded.: MsgBox($MB_SYSTEMMODAL, "Title222", $aFileList[$Fcount]) MsgBox($MB_SYSTEMMODAL, "Title222", ^ ERROR Can anyone of you please help here expandcollapse popup#;NoTrayIcon #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 <GuiEdit.au3> #include <Array.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> ;#include <IniToArray.au3> local $sInfo local $Destination Local $Includebackup Local $Flashballoon = True $timer = TimerInit() Local $Currfile Local $Arrfile Global $INIFilePath = @ScriptDir & "\CurrentDir.ini" $Form1_1 = GUICreate("Backup", 627, 384, 267, 121) $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) #EndRegion ### END Koda GUI section ### 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 _Desktop(true) ElseIf $CopyData= 7 then _Desktop(False) Else _ProcessForm() EndIf Else _ProcessForm() EndIf func _ProcessForm() MsgBox($MB_SYSTEMMODAL, "Title", "else") 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 if _Trim($Destination) = "" Then GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "Destination path is not selected...Please select valid Destination path" & @CRLF, 1) $Flag = False Else ;_MyDocuments() ;_SharedDocuments() ;_Favorites() _Desktop(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 Func _Exitcode() GUIDelete() Exit EndFunc Func _Trim ($LocalString) Return StringStripWS($LocalString, $STR_STRIPLEADING + $STR_STRIPTRAILING) EndFunc func _DisableControls() GUICtrlSetState($BACKUP,$GUI_DISABLE) EndFunc func _EnableControls() GUICtrlSetState($BACKUP,$GUI_ENABLE) EndFunc Func _BackupDestination() $Destination = FileSelectFolder("Select backup destination", "" , 7) 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 Func _IncludeBackup() $IncludeBackup = FileSelectFolder("Select folders to backup", "" , 7) GUICtrlSetData($Input2 , $IncludeBackup) EndFunc Func _BackupSelection() _FileWriteLog(".\Backup.log", $IncludeBackup & " ..............Started @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) 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 @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> Manual selected backup Complete" & @CRLF, 1) EndFunc func GetSourceFiles($SourceDir) local $strPos =StringInStr (StringReverse($SourceDir),"\") Return StringMid($SourceDir,StringLen($SourceDir) - $strPos + 2,$strPos +1) EndFunc Func _MyDocuments() _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Started @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) local $MyDocuments = @MyDocumentsDir local $FolderArray1 = _FileListToArray($MyDocuments & "\", "*", 2) $1 = _ArraySearch($FolderArray1, "RECYCLER") _ArrayDelete($FolderArray1, $1) $Num = $FolderArray1[0] $FolderArray1[0] = $Num - 1 $2 = _ArraySearch($FolderArray1, "System Volume Information") _ArrayDelete($FolderArray1, $2) $Num = $FolderArray1[0] $FolderArray1[0] = $Num - 1 GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "Backing Up Current Users My Documents" & @CRLF, 1) DirCreate($Destination & "\My Documents") ;Call (_Copy("MyDocument")) FileCopy($MyDocuments & "\*.*", $Destination & "\My Documents", 8) For $1 = 1 To $FolderArray1[0] DirCopy($MyDocuments & "\" & $FolderArray1[$1], $Destination & "\My Documents\" & $FolderArray1[$1], 1) Next _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Completed @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> My Documents Backup Complete" & @CRLF, 1) EndFunc ;~ Func _SharedDocuments() ;~ local $SharedDocuments = @DocumentsCommonDir ;~ GuiCtrlSetData($Edit1, @CRLF, 1) ;~ GuiCtrlSetData($Edit1, "Backing Up Shared Documents" & @CRLF, 1) ;~ DirCreate($Destination & "\Shared Documents") ;~ DirCopy($SharedDocuments, $Destination & "\Shared Documents", 1) ;~ GuiCtrlSetData($Edit1, "---> Complete" & @CRLF, 1) ;~ EndFunc Func _Favorites() _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Started @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) local $Favorites = @UserProfileDir & "\Favorites" GuiCtrlSetData($Edit1, @CRLF, 1) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "Backing Up Current Users IE Favorites" & @CRLF, 1) DirCreate($Destination & "\Favorites") DirCopy($Favorites, $Destination & "\Favorites", 1) _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Completed @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> Favorites backup Complete" & @CRLF, 1) EndFunc Func _Desktop($CopyPending) _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Started @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) GuiCtrlSetData($Edit1, @CRLF, 1) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1) DirCreate($Destination & "\Desktop") ;_ArrayDisplay($aFileList, "Sorted tree") if $CopyPending = False then Call (_UpdateIniFile("Desktop",$aFileList)) if $CopyPending then $aFileList = IniReadSection($INIfilePath,"Desktop") ;DirCopy(@DesktopDir, $Destination & "\Desktop", 1) Call (_Copy("Desktop",$aFileList,$Destination & "\Desktop")) _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Completed @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> Desktop backup Complete" & @CRLF, 1) EndFunc 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 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 Func _Compress() _FileWriteLog(".\Backup.log", "Compression" & " ..............Started @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) 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 @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) $Flashballoon = True EndFunc Func _Firefox() _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Started @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) local $Firefox = @AppDataDir & "\Mozilla" If FileExists($Firefox) = 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 DirCopy($Firefox, $Destination & "\Firefox", 1) _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Completed @ " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> Firefox backup Complete" & @CRLF, 1) EndIf $Flashballoon = True EndFunc Func _Copy($SectionName, $aFileList, $Destination) ; 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 For $Fcount = 1 to (Ubound ($aFileList) - 1) MsgBox($MB_SYSTEMMODAL, "Title222", $aFileList[$Fcount]) if (StringInStr($aFileList[$Fcount],".") = 0) then ;if file extention is not available then it is new sub directory $tmpDestination=$Destination & "\" & $aFileList[$Fcount] $test = DirGetSize($Destination & "\" & $aFileList[$Fcount]) ;MsgBox($MB_SYSTEMMODAL, "Title", $test) ;check if new sub directory exists or not. if not then create if (DirGetSize($Destination & "\" & $aFileList[$Fcount]) =-1) then DirCreate($Destination & "\" & $aFileList[$Fcount]) EndIf endIf ;if (StringInStr($aFileList[$Fcount],"\") > 0) then $tmpDestination=$Destination & "\" FileCopy ($aFileList[$Fcount], $tmpDestination) ;alert($aFileList[$Fcount) MsgBox($MB_SYSTEMMODAL, "Title", $aFileList[$Fcount]) IniDelete ($INIfilePath, $SectionName, $aFileList[$Fcount]) Next MsgBox($MB_SYSTEMMODAL, "Title333", "fdffd") EndFunc Func _UpdateIniFile($SectionName,$FileList) ;MsgBox($MB_SYSTEMMODAL, "Title", 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 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, "Desktop")) > 0 then $IsCopyPending = True ExitLoop EndIf Next EndIf Return $IsCopyPending EndFunc  Edited April 18, 2017 by JLogan3o13 Link to comment Share on other sites More sharing options...
benners Posted April 18, 2017 Share Posted April 18, 2017 It means that you are either trying to access a row in the array that is not there (array has 10 rows but code asking for the 11th), or you are trying to access a 1D or 2D array with the wrong code. A quick look  makes me think that it is when you change the number of dimensions of the array with this line if $CopyPending then $aFileList = IniReadSection($INIfilePath,"Desktop") IniReadSection returns a 2D array but the code in _Copy function only allows for 1D. Also, when posting code please use the code tags option '<>' from the toolbar Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 18, 2017 Author Share Posted April 18, 2017 Thanks Benners for responding. Will surely make sure of using code tags next time. Can you please suggest what changes in the code can be done to wipe error ?...im not getting it still  Link to comment Share on other sites More sharing options...
benners Posted April 18, 2017 Share Posted April 18, 2017 I think of a 1D array as a simple list, so using $aFileList[1] will get the value from row 1 of that list. a 2D array is like a table or grid that has multiple colums and Autoit needs to know which column the row is in, so you have to change the code to $aFIleList[1][0]. There is a Wiki about arrays that will help with understanding. With regard to your code, have a look at _ArrayColDelete in the help file. You can use it to delete the column you don't need. The help file shows an example of this. Untested but this might work. Change if $CopyPending = False then Call (_UpdateIniFile("Desktop",$aFileList)) if $CopyPending then $aFileList = IniReadSection($INIfilePath,"Desktop") to If $CopyPending Then $aFileList = IniReadSection($INIFilePath, "Desktop") ;read the files into a 2D array ; delete the column that doesn't have the files in it (I think it's 1) _ArrayColDelete($aFileList, 1, True) ; convert the array to a 1D Else _UpdateIniFile("Desktop", $aFileList) endif You don't need to use Call to call the functions. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 18, 2017 Moderators Share Posted April 18, 2017 @hiteshluthraauto in the future when posting code please use Code tags - see here how to do it. Then you get a scrolling box and syntax highlighting as you can see now in your first post above. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 18, 2017 Author Share Posted April 18, 2017 Many Thanks benners and JLogan3o313 Will surely try the suggestions and get back...thanks again Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 19, 2017 Author Share Posted April 19, 2017 Thanks Gents, That solved desktop copy function and im now able to copy desktop files with folders without issues. Problem now is coming with Favorites and other functions MyDocuments etc where files are not being copied but folders are created...Any suggestions please ? expandcollapse popup#;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 <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, 267, 121) $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) #EndRegion ### END Koda GUI section ### 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 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 Func _Exitcode() GUIDelete() Exit EndFunc Func _Trim ($LocalString) Return StringStripWS($LocalString, $STR_STRIPLEADING + $STR_STRIPTRAILING) EndFunc func _DisableControls() GUICtrlSetState($BACKUP,$GUI_DISABLE) EndFunc func _EnableControls() GUICtrlSetState($BACKUP,$GUI_ENABLE) EndFunc Func _BackupDestination() $Destination = FileSelectFolder("Select backup destination", "" , 7) 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 Func _IncludeBackup() $IncludeBackup = FileSelectFolder("Select folders to backup", "" , 7) GUICtrlSetData($Input2 , $IncludeBackup) EndFunc 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 func GetSourceFiles($SourceDir) local $strPos =StringInStr (StringReverse($SourceDir),"\") Return StringMid($SourceDir,StringLen($SourceDir) - $strPos + 2,$strPos +1) EndFunc Func _MyDocuments($CopyPending) _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Started " ) Local $aFileList = _FileListToArrayRec(@MyDocumentsDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) $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") _FileWriteLog(".\Backup.log", @MyDocumentsDir & " ..............Completed " ) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> MyDocuments Backup Complete" & @CRLF, 1) EndFunc Func _Favorites($CopyPending) _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Started " ) Local $aFileList = _FileListToArrayRec(@UserProfileDir & "\Favorites", "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) GuiCtrlSetData($Edit1, @CRLF, 1) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "Backing Up Current Users IE Favorites" & @CRLF, 1) DirCreate($Destination & "\Favorites") _ProcessCurrentFolderCopy($CopyPending,$aFileList,"Favorites") MsgBox($MB_SYSTEMMODAL, "Title", $aFileList) _FileWriteLog(".\Backup.log", @UserProfileDir & "\Favorites" & " ..............Completed " ) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> Favorites backup Complete" & @CRLF, 1) EndFunc Func _Desktop($CopyPending) _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Started " ) Local $aFileList = _FileListToArrayRec(@DesktopDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) GuiCtrlSetData($Edit1, @CRLF, 1) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "Backing Up Current Users Desktop" & @CRLF, 1) DirCreate($Destination & "\Desktop") ;_ArrayDisplay($aFileList, "Sorted tree") ;if $CopyPending = False then Call (_UpdateIniFile("Desktop",$aFileList)) ;if $CopyPending then $aFileList = IniReadSection($INIfilePath,"Desktop") _ProcessCurrentFolderCopy($CopyPending,$aFileList,"Desktop") _FileWriteLog(".\Backup.log", @DesktopDir & " ..............Completed " ) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> Desktop backup Complete" & @CRLF, 1) EndFunc Func _ProcessCurrentFolderCopy ($ifCopyPending,$arrFileListToCopy,$currentFolderName) 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)) EndFunc 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 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 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 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") _FileWriteLog(".\Backup.log", @AppDataDir & "\Mozilla" & " ..............Completed " ) GuiCtrlSetData($Edit1, " ") GuiCtrlSetData($Edit1, "---> Firefox backup Complete" & @CRLF, 1) EndIf $Flashballoon = True EndFunc 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 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  Link to comment Share on other sites More sharing options...
benners Posted April 19, 2017 Share Posted April 19, 2017 I'm surprised anything copied. It didn't for me. The offending line seems to be in the _Copy function FileCopy($aFileList[$Fcount], $tmpDestination & "\" & $aFileList[$Fcount]) $aFileList[$Fcount] is just the file name, not a full path. The directory the file is in is missing from the file path so the FileCopy fails but there's no notification because there is no error checking. You could also use the additional flag parameters of FileCopy and have it overwrite existing files and create the destination directories for you, then you should be able to remove this code. 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  Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 19, 2017 Author Share Posted April 19, 2017 Thanks for reply Benners Its strange as same code works while copying Desktop files but fails copying files from favorites or others. Its creating folders as desired but not copying . Will try as you suggested first Link to comment Share on other sites More sharing options...
benners Posted April 19, 2017 Share Posted April 19, 2017 I have changed the _Copy function and it is working on my machine with the desktop and favorites folders, not tried with the others. I have had to make some changes. Once you get your code working I would suggest adding some basic error checks to prevent problems later, such as checking an array is an array before you use it. There seems to be a lot of redundant code and globals as well.  I have found this helpful when writing my code. Try this expandcollapse popup# ;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 More sharing options...
benners Posted April 19, 2017 Share Posted April 19, 2017 I had sometime to play about and went overboard .  I have attached the script I ended up with. The Outlook and extra selections aren't coded as I ran out of time but I did copy my desktop, favorites and Firefox folders with it. Using INI files is going to be a bad idea. My Firefox folder has 2406 files and I think every time iniwrite is called it rewrites the whole file, so writing this many lines to it takes an age. I think there is still a 32kb limit on the IniReadSection function as well (workaround) The script is how I try to write mine, and it has changed a lot from your original one. I try to name variables to something understandable and minimize the amount  of Global variables and follow the rules (sometimes) that are laid out in the Wiki I linked to in post #10. It's not meant to replace your script but you can probably get some ideas from it.  There's still room for improvement. benners.au3 Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 20, 2017 Author Share Posted April 20, 2017 Many Many Thanks Benners I am using ini file to check where user left off...just in case utility was abnormally exited or pc shutdown happend....in that case ini file will help in identifying till what path it copied and whats left. Code works perfectly fine now but with one small issue i.e. its not working the big files names and leave their entries on .ini file too for example INI file [Destination] Path=C:\Users\ah0126953\Downloads\Backup Exclude Audio/Video=1 Other Backup= [MyDocuments] [Desktop] C:\Users\ah0126953\Desktop\https--www.amazon.com-dp-B010AI8VMA-ref=twister_B00VMRDFFM_encoding=UTF8&psc=1.url=16 [Favorites] [Firefox] C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-01_16_gzFauBWr1rp8Qh7hNztQFA==.jsonlz4=17 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-02_16_mzgnFieVT0-Ynkbxic5nKA==.jsonlz4=18 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-03_16_U21Wf-kBYmt2dex-t-N9qw==.jsonlz4=19 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-04_16_SVMGQvqs6RrMgSb7pvLCag==.jsonlz4=20 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-05_16_m2YnVoA783FWK5FbCweO7w==.jsonlz4=21 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-06_16_GjiHgvCKKODaN7EEhNcSQg==.jsonlz4=22 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-11_16_D5lNU-2WU25BehS-96RAbQ==.jsonlz4=23 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-13_16_4HZpYIx-DnA9tJFCanTb0A==.jsonlz4=24 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-14_16_3RYWd9iKCy6gL8KJv4yYlA==.jsonlz4=25 C:\Users\ah0126953\AppData\Roaming\Mozilla\Firefox\Profiles\atz8b9dh.default\bookmarkbackups\bookmarks-2017-04-15_16_oPUbrsyHDIIlRfKl1u2NfA==.jsonlz4=26 Here is the full code with added functionality to exclude audio/video files (heavy files though) expandcollapse popup# ;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 ### 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) _BackupSelection($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) IniWrite($INIFilePath, "Destination", "Exclude Audio/Video", GUICtrlRead($Checkbox2)) IniWrite($INIFilePath, "Destination", "Other Backup", GUICtrlRead($Input2)) 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) MsgBox($MB_SYSTEMMODAL, "Title", "test") _Firefox(False) ;_Desktop(False) ;_Favorites(False) ;_MsOutlook() _BackupSelection(False) If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; Must Always Be Last _Compress() 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($CopyPending) 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", @MyDocumentsDir) ;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 GetFileExtention($FileName) Local $strPos = StringInStr(StringReverse($FileName), ".") Return StringMid($FileName, StringLen($FileName) - $strPos + 1, $strPos) 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 _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 = _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") _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, 'Errors', StringReplace($as_FileList[$i], $s_SourceDir, $s_Destination)) if StringInStr(".mp3.mp4.vob.mpeg", GetFileExtention($as_FileList[$i])) = 0 OR GUICtrlRead($Checkbox2) <> $GUI_CHECKED then 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 Else 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 _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 Hopefully this would be the last help for this ....to complete It would be great if someone can help here  Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 20, 2017 Author Share Posted April 20, 2017 Would be great if in this code we can add stuff through which we can copy empty folders too, as its not copying right now. Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 20, 2017 Author Share Posted April 20, 2017 Although files in every case are being copied but its not getting deleted from .ini file.....seems some issues with bigger path. It could be related to multiple folders involved or big file name. Link to comment Share on other sites More sharing options...
benners Posted April 20, 2017 Share Posted April 20, 2017 I saw the ini entries on my test runs as well. I played with the code and before posting did 3 test runs and didn't encounter the issue so thought it was fixed. I think it is due to the fact that those files have multiple =  in the file path and this is affecting the ini delete. With regards to the pending copy and the excessive ini writes, one way would be to initially set an ini entry to show that a copy is in progress and only reset it once the copy is complete. This value could be checked upon program restart like below [Pending] desktop=1 favorites=0 firefox=1 Then if the value was 1 you could scan the source dir "@AppDataDir\Mozilla' and compare it to the backup dir "D:\Backup\Mozilla" and copy and missing files or folders. You could use DirCopy initially and save a lot of coding. A couple of other suggestions are: FileListToArrayRec returns the number of files found in the first element  [0] so you can change the code as follows For $i = 1 To Ubound($as_FileList) -1 to For $i = 1 To $as_FileList[0] You can also specify files and folders to exclude in the $Mask flag so you won't see video type files in the initial list, This saves filtering them out later. To get a files extension instead of Func GetFileExtention($FileName) Local $strPos = StringInStr(StringReverse($FileName), ".") Return StringMid($FileName, StringLen($FileName) - $strPos + 1, $strPos) EndFunc ;==>GetSourceFiles I normally use this, which depending on what you want returned could be just one line ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FAF_FileGetExtensionFromString ; Description ...: Returns a files extension. ; Syntax ........: _FAF_FileGetExtensionFromString($s_Path[, $i_Period = 1]) ; Parameters ....: $s_Path - Full path to the file ; $i_Period - [optional] An integer value. Include the period with the ext i.e .exe. Default is 1. ; Return values .: Success - $i_Period = 0, Returns files extension only. i.e exe ; $i_Period = 1, Returns files exstension and period. i.e .exe ; Author ........: Benners ; Modified ......: ; Remarks .......: ; Example .......: _FAF_FileGetExtensionFromString(C:\Array.au3) ; =============================================================================================================================== Func _FAF_FileGetExtensionFromString($s_Path, $i_Period = 1) If $i_Period Then Return StringRegExpReplace($s_Path, "^.*\.", ".$1") Return StringRegExpReplace($s_Path, "^.*\.", "") EndFunc ;==>_FAF_FileGetExtensionFromString Lastly, is there a reason you want to copy empty folders?, I think it's a bit redundant. Link to comment Share on other sites More sharing options...
benners Posted April 20, 2017 Share Posted April 20, 2017 14 hours ago, hiteshluthraauto said: Would be great if in this code we can add stuff through which we can copy empty folders too, as its not copying right now. Â 13 hours ago, hiteshluthraauto said: Although files in every case are being copied but its not getting deleted from .ini file.....seems some issues with bigger path. It could be related to multiple folders involved or big file name. I have re wrote the code and it is a lot cleaner and simpler now. The above faults are fixed and the files are no longer written to the ini file which has improved the programs speed considerably. Test it against the code that does use ini and you'll see The check box for av files works and these are not copied if selected. You can select multiple extra folders by clicking the browse again and selecting another folder Let me know how you get on. Benners.au3 KickStarter15 1 Link to comment Share on other sites More sharing options...
hiteshluthraauto Posted April 21, 2017 Author Share Posted April 21, 2017 Many many thanks Benners...you made by day. Couldn't express my salute in words. Its flawlessly working .......... Thanks again Link to comment Share on other sites More sharing options...
benners Posted April 21, 2017 Share Posted April 21, 2017 No problem. You can concentrate on adding some error checking and logging and maybe a progress bar Link to comment Share on other sites More sharing options...
KickStarter15 Posted April 22, 2017 Share Posted April 22, 2017 (edited) Hi Guys, Got the same issue in my Desktop and the code given by banners helped. Thanks a lot guys this helps me BIG. We are currently replacing old PCs with newly purchased computers with higher version and everything and I need to back up all files in my desktop and all PCs in our station/department and put it local drive. This thread helped. I was about to post my code looking for solution on how to do this things BUT solved. Now all I need to work is how to run this program in server that all PCs in our station, their Desktop will be copied in their local (for back up) without disturbing them with their work. @hiteshluthraauto, good posting. @bannes, nice work. Â KS15 Edited April 22, 2017 by KickStarter15 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 More sharing options...
benners Posted April 22, 2017 Share Posted April 22, 2017 You could add code that checks for command line arguments and uses the arguments to hide the gui and specify the back up path. Then run the program with the parameters. Backup.exe /runsilent:D:\Backup  Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now