Jump to content

Profile Backup


Recommended Posts

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
   CopyFolder($origdirect, $copydirect)
   If msgbox(1, "Confirmation", "The specified directory doesnt exist. Would you like to create it?") = 1 then
         DirCreate ($copydirect)
         CopyFolder($origdirect, $copydirect)

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)

      $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.")

   Until NOT ProcessExists($ProcID)

   ProgressOff ()

   $copyfilesize = DirGetSize($Folder2)

   If $origfilesize = $copyfilesize then
      Msgbox(0,"Complete", "All files and folders have been copied successfully.")
      Msgbox(0,"Error", "1 or more of the files/folders did not copy correctly.")


Link to comment
Share on other sites

Hi Geomor and welcome to the forums,

This may be due to the way xcopy works in batch script.

EDIT: Further info. The "*.*" symbols in batch script are wildcards that basically mean any filename (the first asterisk) . any file extension (the second).

Try changing your run command to the following, and see how that works for you:

$ProcID = Run(@ComSpec & ' /c xcopy /e /h /r /y /i /d "' & $Folder1 & '\*.*" "' & $Folder2 & '"', "", @SW_HIDE)

- Javi

Edited by javiwhite

give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

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