Connecting to WMI Using the WMI Moniker

Microsoft® Windows® 2000 Scripting Guide

The WMI scripting library provides two distinct mechanisms you can use to establish a connection to WMI on a local or remote computer: the SWbemLocator object (part of the WMI scripting library) and the WMI moniker, "winmgmts:". Other than general usage and syntax differences, the capability that separates the two connection mechanisms is that SWbemLocator lets you specify user and password credentials to be used to establish the connection, and the WMI moniker does not. SWbemLocator is discussed in more detail in the "WMI Scripting Library" section of this chapter.

The WMI moniker enables you use just one line of code to concisely describe a WMI object or collection of WMI objects to manage. However, with power comes the difficulty of constructing complex WMI moniker strings. The following sections of this chapter decipher the components you can use to construct WMI monikers and look at some best practices for writing WMI scripts that use WMI monikers.