Code Script

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Backup My Documents

Vbscript / Files And Folders / Backup My Documents

Backup the contents of the Windows My Documents folder to a specified destination.  Requires robocopy.exe to be in the script folder (or Windows system32 folder). Download robocopy from the Microsoft website in the form of a resource kit.

This script uses Robocopy to continuously monitor the data location and backup soon after changes have been detected effectively keeping the data backed up constantly.

Set objShell = CreateObject("WScript.Shell")

Const USER_PROFILE = &H28&
'Change MY_DOCUMENTS to USER_PROFILE below if desired
Set objFolder = objShell.Namespace(MY_DOCUMENTS)
Set objFolderItem = objFolder.Self

'Log to file (otherwise log to screen)
fLog = false

'Source path (data to backup)
src = objFolderItem.Path

'Destination path (backup location)
dest = "Z:Backup"

sRun = "%comspec% /c robocopy """ & src & """ """ & dest & """ /MON:1 /MOT:5 /TBD /S /MIR"

If fLog = true Then

sRun = sRun & " /XF ""BackupLog.txt"" >""" & src & "BackupBackupLog.txt"""

End If

objShell.Run sRun,2,False

Please note that a disclaimer applies to any code on this page.
  Go Back
  Print Page

- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
     - Exchange
     - Files And Folders
          - Auto Copy Files From Cdrom
          - Backup My Documents
          - Cleanup Filenames
          - Create Remote File Share
          - File Properties
          - File Server Report
          - File Type Report Scan
          - Find And Replace Filename Text
          - Find And Replace Text In Files
          - Folder Size Scanner
          - Rename Files Find And Remove Text
          - Rename Files Find And Replace Text
          - Replace Folder Ntfs Security Permissions
          - Simple File Report
          - Sort And Move Files To Folders
          - Windows File Locations
     - General
     - Ms Office
     - Operating System
     - Processes And Services
     - Text Processing
     - User Interaction
     - Web Servers