Si necesitas guardar el registro de eventos diariamente y archivarlo por fechas…
Simplemente copia este código en un editor de texto y guárdalo como eventviewer.vbs
Crea en la unidad C un directorio de nombre “scripts”, donde guardaremos los backups.
Ejecútalo desde la consola de comandos: ej.: >cscript eventviewer.vbs
Y comprueba el resultado……válido para WXP, W2000 y W2003.
Ahora solo te queda crear una tarea programada para que se ejecute este script cada noche a las 23:59.
…………………….script…………………..
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & “_” & dtmThisMonth & “_” & dtmThisDay
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate,(Backup)}!\\” & _
strComputer & “\root\cimv2″)
Set colLogFiles = objWMIService.ExecQuery _
(“Select * from Win32_NTEventLogFile where LogFileName=’File Replication service’”)
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(“c:\scripts\” & strBackupName & _
“_file_replication_service.evt”)
objLogFile.ClearEventLog()
Next
Set colLogFiles = objWMIService.ExecQuery _
(“Select * from Win32_NTEventLogFile where LogFileName=’System’”)
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(“c:\scripts\” & strBackupName & _
“_system.evt”)
objLogFile.ClearEventLog()
Next
Set colLogFiles = objWMIService.ExecQuery _
(“Select * from Win32_NTEventLogFile where LogFileName=’Security’”)
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(“c:\scripts\” & strBackupName & _
“_security.evt”)
objLogFile.ClearEventLog()
Next
Set colLogFiles = objWMIService.ExecQuery _
(“Select * from Win32_NTEventLogFile where LogFileName=’DNS server’”)
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(“c:\scripts\” & strBackupName & _
“_dnsserver.evt”)
objLogFile.ClearEventLog()
Next
Set colLogFiles = objWMIService.ExecQuery _
(“Select * from Win32_NTEventLogFile where LogFileName=’Directory service’”)
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(“c:\scripts\” & strBackupName & _
“_Directory service.evt”)
objLogFile.ClearEventLog()
Next
Set colLogFiles = objWMIService.ExecQuery _
(“Select * from Win32_NTEventLogFile where LogFileName=’Application’”)
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(“c:\scripts\” & strBackupName & _
“_application.evt”)
objLogFile.ClearEventLog()
Next
………………………………………..