Just discovered a way to use WMI via strongly typed objects. mgmtclassgen.exe (comes with the .net SDK) will take a WMI schema object and generate a class with the object's classes and methods!
mgmtclassgen Win32_NetworkAdapter /P Win32_NetworkAdapter.cs
creates a Win32_NetworkAdapter.cs file that contains a Win32_NetworkAdapter class with all the properties and methods of the WMI object!
To find instances use Win32_NetworkAdapter.GetInstances("=").
No comments:
Post a Comment