WMI what is it and where to start?

    First, what is WMI (Windows Management Instrumentation)? This is a technology that, using a single interface, allows you to manage components of both local and remote operating systems.
    This material is intended for those who have heard something about WMI, but don’t know where to start picking it. And also for those who did not suspect the existence of such a convenient tool.



    I will not talk about how this technology works, if there is interest, information can always be found on MSDN . My goal is to help ensure a quick start, for those who want to start using this technology.

    What gives the application of WMI in practice?The ability to change various parameters of the operating system, manage shared resources, request information about installed devices, running processes, etc.

    Who can use WMI? I think everyone. You can use the WMI capabilities not only from your programs in C #, C ++ and other programming languages, but also create your own scripts that automate the process of collecting information, changing the configuration of a local or remote machine.

    For a quick introduction to the WMI features, you can download the WMI Code Creator utility(size 122 KB, in the archive the utility itself and the source code in C #) from the Microsoft website. This utility allows you to view WMI namespaces, classes of each namespace, properties and methods of each class. Plus, it generates C #, Visual Basic .NET, Visual Basic Script code.



    In order not to get bored for a long time, I will give an example of obtaining information about the installed processor. In the Namespaces list, select root \ CIMV2, in the Classes list (classes), select Win32_Processor. In the Results list (it lists the properties of the class), select Name and click Execute Code. In the window that appears, we see the name (or names) of the installed processor.



    Another example is listing the shared resources. This time we select the Win32_Share class, in the list of properties, select Name then Execute Code. Got a list of resources.



    Let's now close access to some resource, in my case it is Temp. Go to the Execute a Method tab in the list of classes, select the same Win32_Share, in the Methods list select Delete, select the Temp folder, Execute Code, if everything went well, the Temp folder is no longer listed in the list of shared resources.



    If you lack the capabilities of WMI - you can always create your own class. An example of creating such a class has already been published on Habré .

    That's all, I wish you good luck in the development and application of this technology.

    Also popular now: