Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


November 15, 2004

Take Advantage of Scriptomatic 2.0 to Maximize Your WMI Scripting Efforts

It’s not just for novice scripters
RSS
Subscribe to Windows IT Pro | See More Task Automation Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

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:

  1. In the Run dialog box, type
    WBEMTest 
    and press Enter.
  2. In the Windows Management Instrumentation Tester dialog box, click Connect.
  3. Verify that root\DEFAULT appears in the first text box, then click Connect again.
  4. Click the Query button.
  5. In the Query dialog box, enter the query
    select * from StdRegProv
    then select the Retrieve class prototype check box. Click Apply.
  6. In the Query Result dialog box, double-click StdRegProv.
  7. In the Object editor for StdRegProv dialog box, locate the Methods box. Here you'll see all the methods of the StdRegProv class.
  8. To verify that there aren't any local StdRegProv properties, select the Hide System Properties check box. The Properties box should now be empty.
  9. 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.
  10. In the Method Editor dialog box, click the Edit Input Arguments button.
  11. 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:

  1. 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.
  2. When the Connect to namespace dialog box appears, change the path to root\DEFAULT and click OK.
  3. In the WMI CIM Studio Login dialog box, click OK to log on as the current user.
  4. In the directory on the left, click StdRegProv.
  5. In the results pane, click the Methods tab. All the StdRegProv class methods will appear.
  6. 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:

  1. 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.
  2. Click the Query button.
  3. In the Query dialog box, enter the query
    select * from
      IIsCompression-SchemesSetting
    then select the Retrieve class prototype check box. Click Apply.
  4. Double-click IIsCompressionSchemesSetting. In the Properties box that appears, double-click HcDoOnDemandCompression.
  5. 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:

  1. 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.
  2. 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.
  3. 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.
   Previous  1  [2]  3  Next 


Top Viewed ArticlesView all articles
2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...


Task Automation Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement