Clear Event Logs (Win XP)

Author Message
core.ebusiness

  • Total Posts : 17
  • Scores: 0
  • Reward points : 0
  • Joined: 9/20/2010
  • Location: North Jersey
  • Status: offline
Clear Event Logs (Win XP) Tuesday, September 21, 2010 1:39 AM (permalink)
0
For XP -

'System Events':
strComputer = "." 
 Set objWMIService = GetObject("winmgmts:" _ 
     & "{impersonationLevel=impersonate,(Backup)}!\\" & _ 
         strComputer & "\root\cimv2") 
 Set colLogFiles = objWMIService.ExecQuery _ 
     ("Select * from Win32_NTEventLogFile " _ 
     & "Where LogFileName='System'") 
 For Each objLogfile in colLogFiles 
     objLogFile.ClearEventLog() 
     WScript.Echo "Cleared System event log file" 
 Next


'Application Events':
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() 
     WScript.Echo "Cleared application event log file" 
 Next


'Internet Explorer Events':
strComputer = "." 
 Set objWMIService = GetObject("winmgmts:" _ 
     & "{impersonationLevel=impersonate,(Backup)}!\\" & _ 
         strComputer & "\root\cimv2") 
 Set colLogFiles = objWMIService.ExecQuery _ 
     ("Select * from Win32_NTEventLogFile " _ 
     & "Where LogFileName='Internet Explorer'") 
 For Each objLogfile in colLogFiles 
     objLogFile.ClearEventLog() 
     WScript.Echo "Cleared application event log file" 
 Next


'Security Events':
strComputer = "." 
 Set objWMIService = GetObject("winmgmts:" _ 
     & "{impersonationLevel=impersonate,(Backup)}!\\" & _ 
         strComputer & "\root\cimv2") 
 Set colLogFiles = objWMIService.ExecQuery _ 
     ("Select * from Win32_NTEventLogFile " _ 
     & "Where LogFileName='Security'") 
 For Each objLogfile in colLogFiles 
     objLogFile.ClearEventLog() 
     WScript.Echo "Cleared application event log file" 
 Next


the 4 individual files are called from batch files i created and compiled to exe. they can be used individually or in succession from a single batch script.

i have another for Vista/Win7, but it is done via powershell - no vb. :( haha
<message edited by core.ebusiness on Tuesday, September 21, 2010 2:14 AM>
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9