Time stamp file, move event logs then clear them.

Discussion in 'Scripting' started by MisterFixIt, Oct 13, 2004.

  1. MisterFixIt

    MisterFixIt Guest

    I am looking at moving the event logs off a list of servers every thirty
    days. Put the event log in a date specific folder. Then Delete the contents
    of the event logs. This seemed like a simple task. I have started with the
    following:

    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

    I am stuck. Thanks in advanced...ss
     
    MisterFixIt, Oct 13, 2004
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.