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 26 27 28 29
| Option Explicit
Dim X, X2,StrCmd,Source,Cible,Params,OnThisDate
X= DateAdd("d",-1,date())
OnThisDate = Month(x)& "-"& Day(x)& "-" & Year(x)
Source = "F:\DiskFichier"
Cible = "e:\NewDisque\DiskFichier"
Params = " /E /C /H /d:" & OnThisDate
StrCmd = "Xcopy " & DblQuote(Source) &" "& DblQuote(Cible) & Params
'Afficher la commande dans Msgbox pour vérifier si la construction
'de celle-ci est bonne ou non, si oui, on peut alors la supprimer du code
msgbox StrCmd
Call Execute(StrCmd)
'********************************************************************
Function Execute(StrCmd)
Dim ws,MyCmd,Resultat
Set ws = CreateObject("wscript.Shell")
MyCmd = "CMD /C " & StrCmd & ""
Resultat = ws.run(MyCmd,0,True)
If Resultat <> 0 Then
MsgBox "Une erreur inconnue est survenue !",16,_
"Une erreur inconnue est survenue !"
End If
Execute = Resultat
End Function
'********************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'******************************************************************** |