looking for a script that will clear all events in event viewer

Discussion in 'Scripting' started by Michael Noote, Nov 13, 2004.

  1. looking for a script that will clear all events in event viewer
     
    Michael Noote, Nov 13, 2004
    #1
    1. Advertisements

  2. Michael Noote

    Dave Patrick Guest

    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
    objLogFile.ClearEventLog()
    Next

    --
    Regards,

    Dave Patrick ....Please no email replies - reply in newsgroup.
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    http://www.microsoft.com/protect

    :
    | looking for a script that will clear all events in event viewer
     
    Dave Patrick, Nov 13, 2004
    #2
    1. Advertisements

  3. script for some reason not clearing events in event viewer
     
    Michael Noote, Nov 13, 2004
    #3
  4. Michael Noote

    Dave Patrick Guest

    Should have worked. Maybe your AV is blocking the script.

    --
    Regards,

    Dave Patrick ....Please no email replies - reply in newsgroup.
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    http://www.microsoft.com/protect

    :
    | script for some reason not clearing events in event viewer
     
    Dave Patrick, Nov 13, 2004
    #4
  5. Hi thanks for help it works but only clears the application log under event
    viewer not system, directory service, security, and file replication. I want
    to clear event viewer on windows server 2003 thanks alot
     
    Michael Noote, Nov 13, 2004
    #5
  6. Michael Noote

    Dave Patrick Guest

    Try changing;

    ("Select * from Win32_NTEventLogFile Where LogFileName='Application'")
    to read
    ("Select * from Win32_NTEventLogFile")

    --
    Regards,

    Dave Patrick ....Please no email replies - reply in newsgroup.
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    http://www.microsoft.com/protect

    :
    |
    | Hi thanks for help it works but only clears the application log under
    event
    | viewer not system, directory service, security, and file replication. I
    want
    | to clear event viewer on windows server 2003 thanks alot
     
    Dave Patrick, Nov 13, 2004
    #6
  7. worked great thanks youre the best appreciate the help
     
    Michael Noote, Nov 13, 2004
    #7
  8. Michael Noote

    Dave Patrick Guest

    You're welcome.

    --
    Regards,

    Dave Patrick ....Please no email replies - reply in newsgroup.
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    http://www.microsoft.com/protect

    :
    | worked great thanks youre the best appreciate the help
     
    Dave Patrick, Nov 13, 2004
    #8
    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.