vbs ile dosya kopyalama, sonuçları ise mail atma özelliğine sahip.
Yapılması gereken kodlar yedek.vbs adı ile kaydedilmelidir.
kaynak1 ="c:\yedekler"
hedefyer ="H:\MAYIS-2014"
YedekTarih="05-08-2014"
backupcmd1="/Y /E /I /s /d:"&YedekTarih
strSMTPFrom = "test@test.com"
strSMTPTo = "test@test.com"
strSMTPRelay = "10.10.1.1"
strSubject = "File copy completed"
kaynak1 = cleanPath(kaynak1)
hedefyer = cleanPath(hedefyer)
'MsgBox "File Copy Error: " & backupcmd1
Set WshShell = CreateObject ("Wscript.shell")
Set objExec = WSHshell.Exec("xcopy " & chr(34) & kaynak1 & "\SysState\*.*" & chr(34) & " " & chr(34) & hedefyer & "\SysState\" & chr(34) & backupcmd1)
strResult = ""
Do While Not objExec.StdOut.AtEndOfStream
strTemp = objExec.StdOut.ReadLine()
strResult = strResult & vbCRLF & strTemp
Loop
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = "Copy has completed, please review log for success/failure." & vbCRLF & vbCRLF & strResult
oMessage.Send
Function cleanPath(strPath)
If Right(strPath, 3) = "*.*" Then
strPath = Left(strPath, Len(strPath) - 3)
End If
If Right(strPath, 1) = "\" Then
strPath = Left(strPath, Len(strPath) - 1)
End If
cleanPath = strPath
End Function
hedefyer ="H:\MAYIS-2014"
YedekTarih="05-08-2014"
backupcmd1="/Y /E /I /s /d:"&YedekTarih
strSMTPFrom = "test@test.com"
strSMTPTo = "test@test.com"
strSMTPRelay = "10.10.1.1"
strSubject = "File copy completed"
kaynak1 = cleanPath(kaynak1)
hedefyer = cleanPath(hedefyer)
'MsgBox "File Copy Error: " & backupcmd1
Set WshShell = CreateObject ("Wscript.shell")
Set objExec = WSHshell.Exec("xcopy " & chr(34) & kaynak1 & "\SysState\*.*" & chr(34) & " " & chr(34) & hedefyer & "\SysState\" & chr(34) & backupcmd1)
strResult = ""
Do While Not objExec.StdOut.AtEndOfStream
strTemp = objExec.StdOut.ReadLine()
strResult = strResult & vbCRLF & strTemp
Loop
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = "Copy has completed, please review log for success/failure." & vbCRLF & vbCRLF & strResult
oMessage.Send
Function cleanPath(strPath)
If Right(strPath, 3) = "*.*" Then
strPath = Left(strPath, Len(strPath) - 3)
End If
If Right(strPath, 1) = "\" Then
strPath = Left(strPath, Len(strPath) - 1)
End If
cleanPath = strPath
End Function
Hiç yorum yok:
Yorum Gönder
Not: Yalnızca bu blogun üyesi yorum gönderebilir.