Error traping

Tech-Archive recommends: Speed Up your PC by fixing your registry



I have this script below which copies a few folders to a network share
on a server. What i'd like to do it add something so that it logs any
errors that it comes across, e.g. if it can't copy a file because its
in use it would log it then move on to the next file/folder.

Script:

'on error resume next
'Declarations
Set fso = WScript.CreateObject("Scripting.FileSystemObject") 'Standard
File System Object
Set WshNetwork = WScript.CreateObject("WScript.Network") 'Standard
Network Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\documents and settings")
computername=wshNetwork.computername
Outlook = "\Local Settings\Application Data\Microsoft\Outlook"
Set colSubfolders = objFolder.Subfolders
Dim response
BackupDriveLetter = "\\server\share\" 'Where it backs up to.

'Asks to start the backup
response = MsgBox("Would you like to backup the local profiles?", 36,
"Backup Profiles?")

If response = vbYes Then
'BackupDriveLetter = InputBox("Enter backup path")
WScript.Echo "Backup Starting...."
StartBackup() 'Start main Subroutine
Elseif response = vbNo Then
WScript.Echo "Backup Cancelled!"
End If

'Main Program
Sub StartBackup()

objFSO.CreateFolder(BackupDriveLetter & computername) 'Create unique
folder

For Each objSubfolder in colSubfolders

objFSO.CreateFolder(BackupDriveLetter & computername & "\" &
objSubfolder.name ) 'Create Unique folder

If objFSO.FolderExists("C:\Documents and Settings\" &
objSubfolder.Name & "\desktop") Then
objFSO.CopyFolder "C:\Documents and Settings\" & objSubfolder.Name &
"\Desktop" , BackupDriveLetter & computername & "\" &
objSubfolder.Name & "\Desktop" , True
Else
End If

If objFSO.FolderExists("C:\Documents and Settings\" &
objSubfolder.Name & "\My Documents") Then
objFSO.CopyFolder "C:\Documents and Settings\" & objSubfolder.Name &
"\My Documents" , BackupDriveLetter & computername & "\" &
objSubfolder.Name & "\My Documents" , True
Else
End If

If objFSO.FolderExists("C:\Documents and Settings\" &
objSubfolder.Name & "\Favorites") Then
objFSO.CopyFolder "C:\Documents and Settings\" & objSubfolder.Name &
"\Favorites" , BackupDriveLetter & computername & "\" &
objSubfolder.Name & "\Favorites" , True
Else
End If

If objFSO.FolderExists ("C:\Documents and Settings\" &
objSubfolder.Name & Outlook) Then
objFSO.CopyFolder ("c:\Documents and Settings\" & objSubfolder.Name &
outlook) , (BackupDriveLetter & computername & "\" & objSubfolder.Name
& "\Outlook")
Else
End If

Next

wscript.Echo "Backup Complete: Please check backup folder to ensure
backup was successful"

End Sub

.



Relevant Pages

  • Re: Workstation backup
    ... Lanwench give s you the best two possibilities you can use, folder ... risk that offline folder's are not that optimal solution. ... the network with updating only the changes they made in the network ... Therefore solution which will make backup when they are back at the ...
    (microsoft.public.windows.server.general)
  • Re: Workstation backup
    ... Lanwench give s you the best two possibilities you can use, folder redirection and/or offline folders. ... So create a batch file for the users on there desktop to run a robocopy command to copy one special folder from the local machine to the network with updating only the changes they made in the network location. ... Then the user has the option with one mouseclick to backup it's data to the network. ...
    (microsoft.public.windows.server.general)
  • Re: How to automate ASR restore process
    ... Setting up the RIS server to use ASR ... folder on the RIS server, ... make a backup copy of each .osc file before you ...
    (microsoft.public.windows.server.general)
  • Re: windows 2008 system state backup .. HELP ....
    ... Sorry I don't believe i saw info about registry key. ... A network share is a network drive. ... "You cannot store a system state backup on a network shared drive." ... folder local on the server and backup the folder during the normal ...
    (microsoft.public.windows.server.active_directory)
  • Re: windows 2008 system state backup .. HELP ....
    ... As I said in my other post you won't be able to recover your server if you ... Added the registry key and ran a successful backup to c: ... A network share is a network drive. ... folder local on the server and backup the folder during the normal ...
    (microsoft.public.windows.server.active_directory)