Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - Event Scripting with WMI
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

Event Scripting with WMI
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-05-14

    Table of Contents:
  • Event Scripting with WMI
  • Introduction to WMI
  • Using __InstanceCreationEvent
  • Using __InstanceDeletionEvent

  • 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


    Event Scripting with WMI - Introduction to WMI


    (Page 2 of 4 )

    WMI provides a few basic events that, when used properly, can be very useful.  Take for example the __InstanceCreationEvent.  This event allows us to know when something gets created.

    Okay, so what is something?  Well, simply put—whatever we want to watch.  Maybe we want to know when a file is created.  Or perhaps we’d like to know when a new key is added to the registry.  How about knowing when a program starts?

    All right, I’m getting a little carried away.  Let’s take this slowly and look at an example.  We’re going to wait for a file to be created and then delete it.  Why?  Because it’s a pointless example, that’s why.

    I’m going to assume you’ve worked with WMI to some extent before.  If you haven’t, you’ve probably at least seen it.  If not, well, just try to keep up.  It looks intimidating but it’s really not that bad.

    WMI consists of a series of classes that contain information about the environment.  Some of them are intrinsic classes, native to WMI, and some are made available by other Providers. All you really need to understand at this point is that WMI functions somewhat like a database.  All interactions take the form of queries.

    If you know any form of SQL you will find this very easy.  The specific variation used by WMI is known as WQL.

    We begin our script by connecting to the WMI service with the cimv2 provider.  This part should be a snap for you at this point.

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" & strComputer _

       & "rootcimv2")

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


       · Teach your scripts how to react in response to their environment!
     

    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 1 hosted by Hostway
    Stay green...Green IT