Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - Advanced Event Log Parsing in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Advanced Event Log Parsing in WSH
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-05-22

    Table of Contents:
  • Advanced Event Log Parsing in WSH
  • Filtering results
  • More filtering examples
  • Making the code reusable

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Advanced Event Log Parsing in WSH - More filtering examples


    (Page 3 of 4 )

    Let’s take a look at a couple more real-world examples of how you might want to filter results.  We’ll begin with the last challenge I gave you in the last article.  How can you create a script that only returns events for BSODs?

    While the Blue Screen Of Death is dreaded by most users, it can be a very informative tool for system administrators and support specialists.  The BSOD is usually a very good indicator of specific problems in Windows.

    It also returns a unique event.  This makes it possible to filter out only those events that represent BSODs.  Now system and network administrators can monitor these events specifically.

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _

       & "{impersonationLevel=impersonate}!" & strComputer _

       & "rootcimv2")

    Set colEvents = objWMIService.ExecQuery _

       ("Select * from Win32_NTLogEvent Where Logfile = 'System'" _

       & " and SourceName = 'SaveDump'")

    The secret here is the SourceName property.  All BSODs have the value “SaveDump.”

    You could do the same thing with any of the properties:

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _

       & "{impersonationLevel=impersonate}!" & strComputer _

           & "rootcimv2")

    Set colEvents = objWMIService.ExecQuery _

       ("Select * from Win32_NTLogEvent Where Logfile = 'System' " _

           "and EventCode = '6008'")

    This query will return code 6008 events.  These are “Improper Shutdowns.”

    Learn to take advantage of the filtering abilities.  Take a look at your event log and note the properties for the event or events that you want to monitor and then construct your queries accordingly.

    More Windows Scripting Articles
    More By Nilpo/Developer Shed Staff Writer


       · In this article, you'll learn specific ways to customize your event log script for...
     

    WINDOWS SCRIPTING ARTICLES

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT