#NoTrayIcon
#include <Array.au3>
#include <WindowsConstants.au3>
$MainWin= GUICreate('Сохранение настроек', 350, 128, -1, 568)
$Progress = GUICtrlCreateProgress(24, 32, 300, 17)
$BtStart = GUICtrlCreateButton("Старт", 40, 60, 75, 25)
$BtPause = GUICtrlCreateButton("Пауза", 136, 60, 75, 25)
$BtReg = GUICtrlCreateButton("RegOut", 136, 97, 75, 25)
$BtExit = GUICtrlCreateButton('Выйти', 230, 60, 75, 25)
$NameCopy = GUICtrlCreateLabel('', 24, 15, 300, 17)
$Count = GUICtrlCreateLabel('', 325, 15, 300, 25)
GUISetState(@SW_SHOW)
WinSetOnTop('Сохранение настроек', '', 1)
$AppDataLocalDir = 'c:\Users\User\AppData\Local'
$AppDataLocalDirHome = 'd:\Saves\Programs\Users\User\AppData\Local'
$AppDataDirHome = 'd:\Saves\Programs\Users\User\AppData\Roaming'
$ProgramDataDir = 'C:\ProgramData'
$ProgramDataDirHome = 'd:\Saves\Programs\Users\User\ProgramData'
Dim $array[22][2]
$array[1][0] = @AppDataDir & "\Adobe\Adobe Photoshop CS6\Adobe Photoshop CS6 Settings"
$array[2][0] = @AppDataDir & '\Adobe\Adobe Illustrator CS6 Settings'
$array[3][0] = @AppDataDir & '\Adobe\Dreamweaver CS6\Configuration'
$array[4][0] = $AppDataLocalDir & '\Adobe\Flash CS6'
$array[5][0] = @AppDataDir & "\Console"
$array[6][0] = @AppDataDir & '\IndigoRose'
$array[7][0] = @AppDataDir & '\Corel\CorelDRAW Graphics Suite X6'
$array[8][0] = @AppDataDir & '\FileZilla'
$array[9][0] = @AppDataDir & '\NetBeans'
$array[10][0] = @AppDataDir & '\Htpasswd Generator'
$array[11][0] = @AppDataDir & '\SkyMonk'
$array[12][0] = $AppDataLocalDir & '\StarDock\ObjectDockPlus'
$array[13][0] = $AppDataLocalDir & '\Yandex\Praetorian\'
$array[14][0] = @AppDataDir & '\WinRAR\Themes'
$array[15][0] = @AppDataDir & '\Hulubulu\HotKeyMan\Data'
$array[16][0] = @AppDataDir & '\Synaptics\Profiles'
$array[17][0] = $ProgramDataDir & '\Solo9'
$array[18][0] = @AppDataDir & '\Mozilla\Firefox\profiles.ini'
$array[19][0] = @AppDataDir & '\DAEMON Tools Pro\ImageCatalog.xml'
$array[20][0] =@AppDataDir & '\DVDVideoSoft\FreeAudioConverter\FreeAudioConverterProfile.xml'
$array[21][0] = @AppDataDir & '\Microsoft\Windows\Start Menu\Programs\My Apps'
$array[1][1] = $AppDataDirHome & '\Adobe\Adobe Photoshop CS6\'
$array[2][1] = $AppDataDirHome & '\Adobe\'
$array[3][1] = $AppDataDirHome & '\Adobe\Dreamweaver CS6'
$array[4][1] = $AppDataLocalDirHome & '\Adobe\'
$array[5][1] = $AppDataDirHome
$array[6][1] = $AppDataLocalDirHome
$array[7][1] = $AppDataDirHome & '\Corel\'
$array[8][1] = $AppDataDirHome
$array[9][1] = $AppDataDirHome
$array[10][1] = $AppDataDirHome
$array[11][1] = $AppDataDirHome
$array[12][1] = $AppDataLocalDirHome & '\StarDock\'
$array[13][1] = $AppDataLocalDir & '\Yandex\'
$array[14][1] = $AppDataDirHome & '\WinRAR\'
$array[15][1] = $AppDataDirHome & '\Hulubulu\HotKeyMan\'
$array[16][1] = $AppDataDirHome & '\Synaptics\'
$array[17][1] = $ProgramDataDirHome & '\Solo9\'
$array[18][1] = 'd:\Programs\TotalCommander\Launching\Soft\Internet\Firefox\Data\'
$array[19][1] = $AppDataDirHome & '\DAEMON Tools Pro\ImageCatalog.xml'
$array[20][1] = $AppDataDirHome & '\DVDVideoSoft\FreeAudioConverter\FreeAudioConverterProfile.xml'
$array[21][1] = $AppDataDirHome & '\Microsoft\Windows\Start Menu\Programs\'
#include <FileOperations.au3>
#include <File.au3>
Func _CopyDirCopyFile($FileSourch, $FileDest, $ProgressBar = '', $FolderCopy = 1, $FileCopy = 1, $ButtonFuncStop = '')
If Not $FileSourch Then Return 1
If Not $FileDest Then Return 2
Global $ExitFunc = 0, $ButtonStop = $ButtonFuncStop
Local $s = 4096, $a = 1, $b = 1, $size_all = 0, $flag = 0
Dim $szDrive, $szDir, $szFName, $szExt, $Drive, $Dir, $FName, $Ext
$pathcheck = _PathSplit($FileDest, $Drive, $Dir, $FName, $Ext)
If $pathcheck[1] = '' Then Return 4
$var_string = StringReplace($FileSourch, "|", '\', 1)
$path = _PathSplit($var_string, $szDrive, $szDir, $szFName, $szExt)
$attrib_fd = FileGetAttrib($FileSourch)
$fd_s = StringInStr($attrib_fd, 'D')
If Not $fd_s = 0 Then
$flag = 1
$dir_name = StringRegExpReplace($FileSourch, '.*\\', '')
Select
Case $FolderCopy = 0
If FileExists($FileDest & '\' & $dir_name) Then
$dirname = $FileDest & '\' & $dir_name & '_' & @SEC & @MSEC
$result = _FO_FileSearch($FileSourch, '*', True, 125)
If @error Then
$dircopy = DirCopy($FileSourch, $dirname)
If $dircopy = 0 Then
Return 3
Else
GUICtrlSetData($ProgressBar, 100)
Sleep(1000)
GUICtrlSetData($ProgressBar, '')
Return 0
EndIf
EndIf
Else
$dirname = $FileDest & '\' & $dir_name
$result = _FO_FileSearch($FileSourch, '*', True, 125)
If @error Then
$dircopy = DirCopy($FileSourch, $dirname)
If $dircopy = 0 Then
Return 3
Else
GUICtrlSetData($ProgressBar, 100)
Sleep(1000)
GUICtrlSetData($ProgressBar, '')
Return 0
EndIf
EndIf
EndIf
Case $FolderCopy = 1
$dirname = $FileDest & '\' & $dir_name
$result = _FO_FileSearch($FileSourch, '*', True, 125)
If @error Then
$replacepath = StringReplace($path[1] & $path[2], '\', '', -1)
$compare = StringCompare($FileDest, $replacepath)
If $compare = 0 Then
Return 3
Else
$dircopy = DirCopy($FileSourch, $dirname, 1)
If $dircopy = 0 Then
Return 3
Else
GUICtrlSetData($ProgressBar, 100)
Sleep(1000)
GUICtrlSetData($ProgressBar, '')
Return 0
EndIf
EndIf
Else
$replacepath = StringReplace($path[1] & $path[2], '\', '', -1)
$compare = StringCompare($FileDest, $replacepath)
If $compare = 0 Then
Return 3
EndIf
EndIf
EndSelect
Else
$flag = 2
$replace = StringReplace($var_string, '|', '*' & $path[1] & $path[2])
$result = StringSplit($replace, '*')
If $result[0] = 1 Then
If FileExists($result[1]) = 0 Then
Return 1
EndIf
EndIf
$attrib_f = FileGetAttrib($FileDest)
$f_s = StringInStr($attrib_f, 'D')
EndIf
For $i = 1 To $result[0]
If $ExitFunc = 1 Then
Return 6
EndIf
$size = FileGetSize($result[$i])
$size_all += $size
Next
$round = Ceiling($size_all / $s)
$step = Ceiling($round / 100)
$z = 0
$x = 0
GUIRegisterMsg(0x0111, 'WM_COMMAND')
For $r = 1 To $result[0]
If $ExitFunc = 1 Then
GUICtrlSetData($ProgressBar, '')
Return 6
EndIf
Select
Case $flag = 1
Select
Case $FileCopy = 0
If FileExists($dirname & StringReplace($result[$r], $FileSourch, '', 1)) Then
$filenamestring = StringRegExpReplace($dirname & StringReplace($result[$r], $FileSourch, '', 1), '.*\\', '')
$pathreplace = StringReplace($dirname & StringReplace($result[$r], $FileSourch, '', 1), $filenamestring, '', -1)
$filedestname = $pathreplace & @SEC & @MSEC & '_' & $filenamestring
Else
$filedestname = $dirname & StringReplace($result[$r], $FileSourch, '', 1)
EndIf
Case $FileCopy = 1
$filedestname = $dirname & StringReplace($result[$r], $FileSourch, '', 1)
EndSelect
Case $flag = 2
If Not $f_s = 0 Then
Select
Case $FileCopy = 0
If FileExists($FileDest & '\' & StringRegExpReplace($result[$r], '.*\\', '')) Then
$filenamestring = StringRegExpReplace($result[$r], '.*\\', '')
$pathreplace = StringReplace($FileDest, $filenamestring, '', -1)
$filedestname = $pathreplace & '\' & @SEC & @MSEC & '_' & $filenamestring
Else
$filedestname = $FileDest & '\' & StringRegExpReplace($result[$r], '.*\\', '')
EndIf
Case $FileCopy = 1
$filedestname = $FileDest & '\' & StringRegExpReplace($result[$r], '.*\\', '')
EndSelect
Else
$filedestname = $FileDest
EndIf
EndSelect
$hFile = FileOpen($result[$r], 16)
If $hFile = -1 Then
$z = $z + 1
ContinueLoop
EndIf
$folderdestname = FileOpen($filedestname, 2 + 8 + 16)
If $folderdestname = -1 Then
FileClose($hFile)
$x = $x + 1
ContinueLoop
EndIf
While 1
If $ExitFunc = 1 Then
GUICtrlSetData($ProgressBar, '')
FileClose($hFile)
FileClose($folderdestname)
FileDelete($filedestname)
Return 6
EndIf
$sChars = FileRead($hFile, $s)
If @error = -1 Then
ExitLoop
ElseIf @error = 1 Then
ExitLoop
EndIf
$file_w = FileWrite($folderdestname, $sChars)
If $file_w = 0 Then ExitLoop
If $b = $step * $a Then
GUICtrlSetData($ProgressBar, $a)
$a = $a + 1
EndIf
$b = $b + 1
If $b = $round Then
GUICtrlSetData($ProgressBar, 100)
EndIf
WEnd
FileClose($hFile)
FileClose($folderdestname)
$attrib = FileGetAttrib($result[$r])
FileSetAttrib($filedestname, $attrib)
Next
$emptyfolder = _FO_SearchEmptyFolders($FileSourch, 1)
If Not @error Then
For $i = 1 To $emptyfolder[0]
$pathdestreplace = StringReplace($emptyfolder[$i], '\', '', -1)
$emptyfoldername = $dirname & StringReplace($pathdestreplace, $FileSourch, '', 1)
DirCreate($emptyfoldername)
Next
EndIf
If $z = 0 And $x = 0 Then
GUICtrlSetData($ProgressBar, 100)
Sleep(1000)
GUICtrlSetData($ProgressBar, '')
Return 0
ElseIf $z = UBound($result) - 1 Or $x = UBound($result) - 1 Then
Return 4
Else
GUICtrlSetData($ProgressBar, 100)
Sleep(1000)
GUICtrlSetData($ProgressBar, '')
Return 5
EndIf
EndFunc
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0xFFFF)
Switch $nNotifyCode
Case 0
Switch $nID
Case $ButtonStop
$ExitFunc = 1
EndSwitch
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc