Streamlines access to the
WMI.
System Object CleanCode.Net WMIHelperNamespace: CleanCode.NetAssembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
public ref class WMIHelper
public ref class WMIHelper
WMI (Windows Management Instrumentation)
allows querying remote computers for key data.
The full WMI allows control of remote computers as well.
WMIHelper provides some support methods to streamline access.
For a list of sections and keys, see the
WMI reference.
Also,
WMI Explorer
is useful for actually exploring values returned by WMI.
Since CleanCode 0.9.07.
The first step is to create an instance using one of the
constructors. You may specify a remote host with or without a section:
wmiHelper = new WMIHelper(server, domain, user, pwd);
wmiHelper = new WMIHelper(server, domain, user, pwd, section);
wmiHelper = new WMIHelper(server, domain, user, pwd);
wmiHelper = new WMIHelper(server, domain, user, pwd, section);
wmiHelper = new WMIHelper();
wmiHelper = new WMIHelper(section);
wmiHelper = new WMIHelper();
wmiHelper = new WMIHelper(section);
or a local host likewise:
Next invoke the
Connect method to connect the scope.
And now you are ready to execute queries. If you pre-selected a
section in the constructor, you only need the single-argument
GetInfo(String).
If you did not, or you want to change the section,
then you use the
SetSection(String) method or the
dual-argument
GetInfo(String, String).
wmiHelper.SetSection("Win32_OperatingSystem");
string serverOSName = wmiHelper.GetInfo("Caption");
string serverIPLabel = wmiHelper.GetInfo(
"Win32_NetworkAdapterConfiguration", "IPAddress");
wmiHelper.SetSection("Win32_OperatingSystem");
string serverOSName = wmiHelper.GetInfo("Caption");
string serverIPLabel = wmiHelper.GetInfo(
"Win32_NetworkAdapterConfiguration", "IPAddress");