Articles
|
|
Please use FireFox to view this page
This website has been designed for use with the FireFox browser. Please use FireFox to view this page.
9.0 WMI query analyser, in C# and VB.NET
Windows Management Instrumentation, (WMI) is a common object
model for a host of technical information about a systems hardware and software
configuration. It can be used to query either a local machine, or if
permissions allow, a remote computer. This technology can be used to enumerate
and detail any of the following aspects of the operating system:
- List,
start, stop and suspend services
- List,
Start (spawn) and stop processes
- Read
the NT event log
- Enumerate
Hard-drives, CD-Rom drives, Partitions etc.
- Read
computer operating specifics (CPU speed, memory etc.)
- Read
BIOS settings
- Get
Network adapter-specific information, such as MAC addresses.
- Query
WDM (Windows Driver Model) devices, such as Web-cameras
- Read
& write to remote Windows registries
- Query
the Active Directory
Although each of the above actions may be performed using
low-level windows API calls, or in certain other cases, other classes within
.NET. However WMI provides a simple all-encompassing namespace/class object
model, putting this wealth of information at your fingertips. Furthermore, it
gives the ability to perform all of these actions remotely, without the need
for a custom-built server application.
To give an example, imagine you wanted to develop a system
to automatically deploy software patches on an enterprise-wide basis. In order
to get each computer to accept, and execute these patches, you would need to
develop a service that could listen for requests to execute these executables,
build some form of authentication mechanism for security, then deploy this
service to all computers on the network. Alternatively, if you used WMI, you
could use one central computer to send WMI requests to all the computers on
your network to install the patch, et viola, no need for the deployment of a
custom server.
WMI is a huge subject, so therefore it is practically impossible
to provide a comprehensive example program that covers anything. However, this
application can be used to make WQL (WMI query language) on the root\cimv2
namespace of the CIM (Common Information Model). The book Network
programming in .NET (Buy at Amazon UK)
(Buy at Amazon US) covers a much wider scope of WMI, and explains how to
leverage it to access the bounty of information held within this vast, yet
simple object model.
To use this application, type in the name of a remote
computer (or localhost) into the space provided. If you require different
account privileges, then you must also provide the NT username and password for
this computer in the spaces provided. You may then type a WQL query into the
‘Query’ box, and press ‘Execute’. In the example below, we have used “select *
from Win32_NetworkAdapterConfiguration” (see screenshot below)

(Source code availabile in the book Network Programming in .NET (Buy at Amazon UK)
(Buy at Amazon US), Chapter 12,
example 4)
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8
Page 9
Page 10
Page 11
Page 12
Page 13
Copyright 2017 Infinite Loop Ltd.
|