天天看點

備份和清除事件日志

描述

備份和清除應用程式事件日志。

腳本代碼

strComputer = "."

Set objWMIService =

GetObject("winmgmts:" _

   & "{ impersonationLevel=impersonate,(Backup)

}!\\" & _

       strComputer & "\root\cimv2")

Set colLogFiles =

objWMIService.ExecQuery _

   ("Select * from Win32_NTEventLogFile where

LogFileName='Application'")

For Each objLogfile in colLogFiles

 errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")

   If

errBackupLog <> 0 Then        

       Wscript.Echo "The Application

event log could not be backed up."

   Else

 objLogFile.ClearEventLog()

   End If

Next

本文轉自 蘇繁 51CTO部落格,原文連結:http://blog.51cto.com/goxia/221141,如需轉載請自行聯系原作者

繼續閱讀