Welcome to MSDN Blogs Sign in | Join | Help

Windows Management Infrastructure Blog

Managing your IT infrastructure remotely, securely, reliably and efficiently
Writing WMI provider in a day

Writing WMI provider in native code has steep learning curve. It involves writing MOF files and implementing methods from IWbemServices and IWbemProviderInit interfaces. Sometimes it becomes difficult and time consuming to debug issues in the WMI provider.

WMI.Net Provider Extension 2.0 was first introduced in Visual studio 2008 and is part of .Net Framework 3.5. It is based on the attribution model where MOF files are generated automatically and developers doesn’t have to implement any of the methods from the IWbemProviderInit or IWbemServices interfaces. Attributes can be added at the assembly, class, properties or method levels to specify what part of the managed application exposes WMI functionality. WMI.Net Provider Extension 2.0 generates MOF file and register it automatically based on the information provided in the attributes.

WMI.Net Provider Extensions 2.0 can be used to write both coupled providers and decoupled providers. There is a very good article on writing coupled providers here .

Writing WMI Providers in WMI.Net Provider extension 2.0 is fairly easy to write and debug. To give an idea I was able to write my own Win32_Process class with extended functionality in less than a day.

Posted: Friday, June 19, 2009 10:05 PM by nitingup

Comments

a dev said:

debugging this is a nightmare. WMI is poorly designed when it comes to debugging wmi providers.

# July 8, 2009 7:16 PM

kmathur said:

Do let us know if you have any suggestions to improve the debugging experience.

# July 23, 2009 8:49 PM

bm said:

WMI provider using System.Management.Instrumentation (WmiConfiguration) sucks. Writing is simple, but testing to see if it works is hell of a deal.

I wrote a simple windows forms application and with a WMI provider class (very basic with a key and two readonly properties), installed it using installutil and then published the instance of the class. Wbemtest wouldn't show any instances. No matter what i tried.

However if I use Instrumented attribute and associated classes, it works.

I can't figure out what is it that I am missing.

# October 2, 2009 3:46 PM

mabra said:

Hi !

Thanks for this pointer!

But:This is a badly written article, because it starts very deep, giving you no chance to understand the code without first studying the SDK ... do I have to implement my own process, or not?? Ok, I am searching ...

Although WMI is very important and generally a good thing, it is - facing it's complexity - a underdocumented thing. This moment, I was looking for all classes which are singletons:You have no hope with the SDK [no overviews/tables with details]. As alway, I stranded to write the next hack ....

MS should really start to make some quality control [not only for the software, but for their articles also!] and finally implement the wmi properties, administrators are looking for [yes, the huge amount of NULL values, like fileCRC, stati - withound end!].

And it looks like, MS is interested mostly to have a good layer for SMS/MOM and so important providers [compare windows xp to server 2003] are removed, which could admins a good help!

Just my two cents. I am using WMI sinde the beginning.

br--mabra

# November 12, 2009 5:52 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker