window 環境下vb 監控指令碼!

來源:互聯網
上載者:User

標籤:window   監控   


檔案監控


DIM  strDate   

DIM  strDatestringOld

DIM  strPath01 , strPath02,strPath03

DIM fs

DIM  Textbody 


strDate = Date

strDatestringOld=Year(strDate) & Right("0" & Month(strDate),2) & Right("0" & Day(strDate),2)&".rar"


strPath="D:\backup\10.65.14.61\"&strDatestringOld

strPath01="D:\backup\10.65.14.61\"&strDatestringOld


set fs =createobject("scripting.filesystemobject")


If fs.fieExists(strPath01)=fales Then

  Textbody = "以下備份檔案未產生" & vbcrlf & strPath01

End If


If fs.fieExists(strPath02)=fales Then

  Textbody =Textbody & vbcrlf & strPath02

End If


if Textbody <>"" then

 call  CheckFile(Textbody) 

end if 


‘定義一個函數,檢查每天的備份是否產生


function CheckFile(byval TextBody )

   Const Email_From = "[email protected]" ‘寄件者郵箱 

Const Password = "DW_chaoyue" ‘寄件者郵箱密碼 

Const Email_To = "[email protected];[email protected]" ‘收件者郵箱 


Set CDO = CreateObject("CDO.Message") ‘建立CDO.Message對象 

CDO.Subject = "警告:備份檔案異常"  ‘郵件主題 

CDO.From = Email_From ‘寄件者地址 

CDO.To = Email_To ‘收件者地址 

CDO.TextBody = TextBody ‘郵件內文 

‘cdo.AddAttachment = "C:\hello.txt" ‘郵件附件檔案路徑 

Const schema = "http://schemas.microsoft.com/cdo/configuration/" ‘規定必須是這個,我也不知道為什麼 


With CDO.Configuration.Fields ‘用with關鍵字減少代碼輸入 

.Item(schema & "sendusing") = 2 ‘使用網路上的SMTP伺服器而不是本地的SMTP伺服器 

.Item(schema & "smtpserver") = "smtp.163.com" ‘SMTP伺服器位址 

.Item(schema & "smtpauthenticate") = 1 ‘伺服器認證方式 

.Item(schema & "sendusername") = Email_From ‘寄件者郵箱 

.Item(schema & "sendpassword") = Password ‘寄件者郵箱密碼 

.Item(schema & "smtpserverport") = 25 ‘SMTP伺服器連接埠 

.Item(schema & "smtpusessl") = True ‘是否使用SSL 

.Item(schema & "smtpconnectiontimeout") = 60 ‘串連伺服器的逾時時間 

.Update ‘更新設定 

End With 


 CDO.Send ‘發送郵件 

 

End function 


代碼參考連結:

http://www.jb51.net/article/26105.htm



本文出自 “SQLServer MySQL” 部落格,請務必保留此出處http://dwchaoyue.blog.51cto.com/2826417/1539852

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.