Understanding WMI Scripting

A moniker is a string (also called a display name) that provides a location and an identity to an object that must be instantiated in a script. This term comes from the COM object programming and represents another programmatic identifier (called ProgID) that maps to a class identifier (called CLSID). This CLSID points to a COM object implemented as a .dll containing the desired object. To define the location and the identity of an object, the moniker uses a syntax that is specific to any implementation. The WMI moniker is a string that combines some WMI-specific information with a WMI object path. That string is used to access information exposed by WMI. The specific information of a WMI moniker contains:
A namespace (WinMgmts: for WMI)
Some optional localization data
Some optional security settings used for the object instantiation
The string "WinMgmts:" is not case sensitive and is dedicated to refer to WMI monikers. This will make the system point to the WBEMDISP.Dll located in %SystemRoot\System32\WBEM directory that is the .dll containing the WMI scripting COM API. Let's take a sample. In the previous paragraph, we saw an instance object path for the SNMP service. The moniker used to instantiate this Win32_Service instance in a script is
WinMgmts:\\NET-DPEN6400A\Root\CIMv2:Win32_Service.Name=" SNMP"
To access this object instance in a script, the code can be written in VBScript as follows:
Set objWMIInstance = GetObject("WinMgmts:\\NET-DPEN6400A\Root\CIMv2:Win32_Service.name=""SNMP""")You will notice the double quotes to respect the VBScript syntax. To ease reading this in...