1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Option Explicit
On Error Resume Next
Dim FSO,Source,Destination
Set FSO = CreateObject("Scripting.FileSystemObject")
Source = "E:\VM"
Destination = "F:\backup\Sauvegarde_du " & Day(Now) & "-" & Month(Now) & "-" & Year(Now) & "\"
Call CreateFolderRecursive(Destination)
FSO.CopyFolder Source,Destination
If Err <> 0 Then
MsgBox Err.Description,VbCritical,Err.Description
wscript.Quit()
End If
'********************************************************************
Function CreateFolderRecursive(FullPath)
Dim arr,dir,path,FSO
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
arr = split(FullPath, "\")
path = ""
For Each dir In arr
If path <> "" Then path = path & "\"
path = path & dir
If FSO.FolderExists(path) = False Then FSO.CreateFolder(path)
Next
End Function
'******************************************************************** |
Partager