Martin de Klerk
Born in 1958 and bitten by the computer-bug in 1976, I am an autodidact to the letter.
Through the years I have:
- accumulated programming experience ranging from writing device-drivers to developing advanced MIS programs.
- mastered languages like Assembler, C/C++/C#, (several flavours of) Basic, Cobol, Forth, Eiffel and Clipper
- filled nearly every job/position the IT world has to offer as employee or contractor.
- worked with customers ranging from your local grocery-shop, farmers, hospitals, offshore companies, governemental departments to multinationals like Shell, Afga-Gevaert, ABN/AMRO and Phillips N.V.
Currently I am:
View all articles by Martin de Klerk...
- running my own consultancy business since 1993.
- developing 80% of my solutions in VB.NET
- dividing my sparse moments of free time between my family, music (especially enjoy jamming with my son : on the guitar he's the gifted one, I just manage a bit of semi-decent guitar/harmonica play) and VBCity.
- eagerly awaiting the official release of .NET Framework 2.0
When you're new to WMI, I suggest you start with ( aside from a lot of reading up) downloading CIM-Studio and ScriptoMatic 2.0. These two utilities will provide you with an easy way to explore the WMI namespaces, classes and objects. Although script-driven, links are provided at the end of this article. Also download the WMI SDK for the documentation.
As I told you before, this was my first involvement in WMI. As such, I can only conclude that my way of coding works (or not) but I can not vouch for doing it the proper WMI way. WMI delivers a very powerful functionality , but ONLY when all (sub)systems involved (like DCOM, RPC, SMNP, Firewall, Group Policies, etc) are working in perfect harmony. If not working in perfect harmony, you easily find yourself looking for the needle in the proverbial haystack.
I will give you an example: during the development of the printer monitor program, I was forced to poll the printerservers while WMI offers a lot of goodies I'd like to use instead, like the ManagementEventWatcher class. This class triggers an event when a selected event (like the creation of a print job) took place. My intention was to create a service for printerservers which would inform my monitor program on printer-states and printing progress. As WMI contains the possibility to remotely create and start services and processes (so manual installation of my service was not required: no-touch deployment!) this approach would also reduce the network traffic to the minimum and free up resources on the computer running the monitor program. Programmers heaven, one should think.
Alas, after two weeks of struggling with the ManagementEventWatcher class I still got a 'method not supported' exception when I tried to invoke the ManagementEventWatcher.Start() method with VB.NET code. After having scavenged the WMI logfiles (stored in \windows\system32\wbem) , MSDN, forums, newsgroups and other Internet resources on this topic I gave up and concluded that I stumbled upon yet another OS dependency. So I had to revert to the polling approach to retain compatibility with other versions of Windows. Maybe an actual Windows server is needed to make use of this class in VB.NET, I do not know. Now when I'm wrong or overlooking the obvious, I'll happily stand corrected: - email@example.com .
Now, before you start hitting the e-mail button, let me show you the signature of one of VBCity's oldest (membership-wise that is) and esteemed members: CanOz. He selected a quote from George Bernard Shaw, which I find totally spot on:
I am not a teacher
only a fellow traveller of whom you asked the way.
I pointed ahead
ahead of myself as well as of you.
Say no more....
List of Helpful Links:
Using WMI with the .NET Framework
Accessing Management Information with System.Management
Operating System Availability of WMI Components
WMI Win32 Classes
WMI Administrative Tools (including CIM studio)