Hi Guys,
New to the scripting scene so bare with me here, I am having some torubles with my script. I found a script that copies a folder from source to destination that shows a progress bar on the forums here. The sole purpose of the script is to create an incremental backup of users profile to a server.
Now I have set the source folder to the profile directory on a win7 machine, @UserProfileDir should be sufficeient for this? Once i run the script it doesnt copy a single file and displays no errors. I understand not all files will be copied due to locked/in use files but that is okay.
Any help would be greatly appreciated
I have attached the script below
$origdirect = @UserProfileDir
$copydirect = "C:\temp\test"
;DriveMapAdd ("X:","\\test\temp")
If FileExists ($copydirect) then
If msgbox(1, "Confirmation", "The directory already exists. Are you sure you want to replace it?") = 2 Then Exit
;Else
CopyFolder($origdirect, $copydirect)
Else
If msgbox(1, "Confirmation", "The specified directory doesnt exist. Would you like to create it?") = 1 then
DirCreate ($copydirect)
CopyFolder($origdirect, $copydirect)
Else
Exit
EndIf
EndIf
Func CopyFolder($Folder1, $Folder2)
Local $ProcID
$ProcID = Run(@ComSpec & ' /c xcopy /e /h /r /y /i /d "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE)
ProgressOn("Progress Meter", "")
$origfilesize = DirGetSize($Folder1)
Do
$copyfilesize = DirGetSize($Folder2)
$MB = dirGetSize($Folder2) / 1024 / 1024
$percent = $copyfilesize / $origfilesize * 100
$decimalplace = Round ($percent)
$decimalplaceMB = Round ($MB)
ProgressSet ($percent, $decimalplace & " % " & "(" & _
$decimalplaceMB & ") Mb has been copied.")
Sleep(500)
Until NOT ProcessExists($ProcID)
ProgressOff ()
$copyfilesize = DirGetSize($Folder2)
If $origfilesize = $copyfilesize then
Msgbox(0,"Complete", "All files and folders have been copied successfully.")
Else
Msgbox(0,"Error", "1 or more of the files/folders did not copy correctly.")
EndIf
EndFunc
DriveMapDel("X:")