Sometimes What You Aren't Told Is a Clue
If you select a class and generate a script that returns few or no properties, you might have encountered a class with useful methods. For example, if you use Scriptomatic 2.0 to create a script for the StdRegProv class in the root\DEFAULT namespace, you'll see that StdRegProv doesn't contain any properties. (Technically, StdRegProv contains global system properties, but Scriptomatic doesn't display these types of properties because they're of little value from an administrative scripting perspective.) To determine whether a class has useful methods, you can use WBEMTest. Follow these steps to see for yourself what the StdRegProv class contains:
- In the Run dialog box, type
WBEMTest
and press Enter.
- In the Windows Management Instrumentation Tester dialog box, click Connect.
- Verify that root\DEFAULT appears in the first text box, then click Connect again.
- Click the Query button.
- In the Query dialog box, enter the query
select * from StdRegProv
then select the Retrieve class prototype check box. Click Apply.
- In the Query Result dialog box, double-click StdRegProv.
- In the Object editor for StdRegProv dialog box, locate the Methods box. Here you'll see all the methods of the StdRegProv class.
- To verify that there aren't any local StdRegProv properties, select the Hide System Properties check box. The Properties box should now be empty.
- To see the input parameters (also called properties) for a specific method, you can double-click a method. For example, double-click the CreateKey method.
- In the Method Editor dialog box, click the Edit Input Arguments button.
- In the Object editor for __Parameters dialog box, make sure that the Hide System Properties check box is selected. You'll see two input parameters in the Properties box: hDefKey and sSubKeyName. If you used the CreateKey method, the hDefKey parameter's value will be an integer that represents the registry key in which you created your new subkey. The sSubKeyName parameter's value will be a string that specifies the new subkey's pathname. Note that you can use the WMI SDK to review the numeric values of registry keys.
If you've installed the WMI Administrative Tools, you can view similar information with CIM Studio. Follow these steps to view the StdRegProv methods in CIM Studio:
- Open CIM Studio. If you've installed XP Service Pack 2 (SP2) with pop-up blocking, you have to select Allow Blocked Content so that CIM Studio (an IE application with active content) can run.
- When the Connect to namespace dialog box appears, change the path to root\DEFAULT and click OK.
- In the WMI CIM Studio Login dialog box, click OK to log on as the current user.
- In the directory on the left, click StdRegProv.
- In the results pane, click the Methods tab. All the StdRegProv class methods will appear.
- Right-click a method, such as CreateKey, then click Edit Method Parameters to view the method's input parameters.
After you learn which methods and properties are (or aren't) available in a class, you can obtain more information about them from the Microsoft Developer Network (MSDN) Library or the WMI SDK. For example, you can read about the StdRegProv class's CreateKey method in the MSDN Library at http://msdn.microsoft.com/library/default.asp?url=/library/enus/wmisdk/wmi/createkey_method_in_class_stdregprov.asp.
As the StdRegProv example illustrates, the lack of properties often suggests that a class has a rich set of methods. However, a class with many properties might also contain a rich set of methods. For example, the Win32_Share class in root\CIMV2 contains 10 nonsystem properties and four methods. Therefore, don't assume that a class containing nonsystem properties will contain no useful methods.
What You See Isn't Necessarily All You Get
Scriptomatic 2.0 is a great tool for quickly learning the properties of a class, but it won't tell you anything about whether those properties are read-only or writeable. However, in many cases, you can deduce whether a property is read-only or writeable just by the type of class to which the property belongs. Take, for example, the Win32_BIOS class in the root\CIMV2 namespace. It's atypical for an application to write changes to the BIOS outside of the BIOS setup utility, so the Win32_BIOS class contains read-only properties, such as BIOSVersion and Manufacturer.
Other classes, such as IIsCompressionSchemesSetting of the root\MicrosoftIISv2 namespace, contain a plethora of writeable properties. You can use WBEMTest or CIM Studio to verify that properties are writeable. The following procedures on how to use these tools for this purpose are abbreviated because I explained earlier how to use WBEMTest and CIM Studio. To check for writeable properties with WBEMTest, follow these steps:
- On a computer running Windows 2003 and IIS 6.0, connect to the root\ MicrosoftIISv2 namespace. Note that you can use WBEMTest to connect to a remote computer by appending \\computer name (where computer name is the name of the computer to which you want to connect) to the namespace path appearing in the Connect dialog box.
- Click the Query button.
- In the Query dialog box, enter the query
select * from
IIsCompression-SchemesSetting
then select the Retrieve class prototype check box. Click Apply.
- Double-click IIsCompressionSchemesSetting. In the Properties box that appears, double-click HcDoOnDemandCompression.
- Notice that write is set to True in the Qualifiers box and that the CIM type is Boolean.
To check for writeable properties in CIM Studio, follow these steps:
- On a computer running Windows 2003 and IIS 6.0, connect to the root\MicrosoftIISv2 namespace. You can connect to a remote computer from CIM Studio by specifying \\computer name in the Machine Name text box of the Browse for Namespace dialog box.
- In the directory, expand the CIM_Setting\IIsSetting path, then click IIsCompressionSchemesSetting. In the results pane, a writeable property has a special icon. Figure 1 shows the icon for writeable inherited properties. Figure 2 shows the icon for writeable local properties. You can also see whether a property is writeable by following the next step.
- In the results pane, double-click a property, such as HcDoOnDemandCompression. In this case, you'll see that the write value is set to True and the CIM type is Boolean.