' CopyUserFiles.vbs
' VBScript for copying the Document and User files to another directory
' Coded for Windows XP but can be adapted for 2000 / Vista by changing
' FavoritesFolder, DesktopFolder, MyDocumentsFolder, strFilePath, and strDestination to suit your needs
'
' Program runs silently while copying. It may take a while to copy large files.
' A messagebox will pop up when finished.
'
' Author: Eric Wong http://circledock.wikidot.com
' Version 1.0 - 4th September 2008
' ----------------------------------------------------------
Option Explicit
Dim objFSO_DIR, objFolder, objCopyFolder, colSubfolders, objSubfolder
Dim objFSO, objFileCopy
Dim strFilePath, strDestination
Dim fileChecker, objShell
Const OverWriteFiles = True
Const FavoritesFolder = "\Favorites"
Const DesktopFolder = "\Desktop"
Const MyDocumentsFolder = "\My Documents"
strFilePath = "C:\Documents and Settings"
strDestination ="C:\New Documents and Settings"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fileChecker = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
'Set objCopyFolder = CreateObject("Shell.Application")
objFSO.CreateFolder(strDestination)
Set objFSO_DIR = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO_DIR.GetFolder(strFilePath)
Set colSubfolders = objFolder.Subfolders
'This is the core of the file copying process
For Each objSubfolder in colSubfolders
Set objFolder = objFSO.CreateFolder(strDestination & "\" & objSubfolder.Name)
If fileChecker.FolderExists(objSubfolder & FavoritesFolder) = True Then
fileChecker.CopyFolder objSubfolder & FavoritesFolder, objFolder & FavoritesFolder, OverWriteFiles
End If
If fileChecker.FolderExists(objSubfolder & DesktopFolder) = True Then
fileChecker.CopyFolder objSubfolder & DesktopFolder, objFolder & DesktopFolder, OverWriteFiles
End If
If fileChecker.FolderExists(objSubfolder & MyDocumentsFolder) = True Then
fileChecker.CopyFolder objSubfolder & MyDocumentsFolder, objFolder & MyDocumentsFolder, OverWriteFiles
End If
Next
WSCript.Echo "Finished copying selected folders from " & strFilePath & " to " & strDestination
Wscript.Quit