Previous Page
Next Page

One Step Further: Echoing the Time Zone

In this section, you modify the SBSQueryHotFix.vbs script so that it echoes out the time zone configured on the computer.

1.
Open \My Documents\Microsoft Press\VBScriptSBS\ch08\OneStepFurther\SBS QueryHotFix.vbs in Notepad or another script editor and save it as YourName TimeZoneSolution.vbs.

2.
Edit the wmiQuery line so that it points to Win32_TimeZone. The code will look like the following:

wmiQuery = "Select * from Win32_TimeZone"

3.
Inside the For Each objItem In colItems loop, delete all but one of the WScript.Echo statements so that the code looks like the following:

For Each objItem In colItems
    WScript.Echo "Caption: " & objItem.Caption
Next

4.
Save and run the file. You are now pointing to the Caption property of Win32_TimeZone in your script. No further changes are required for this section. If you have a problem, compare your script to the TimeZoneSolution.vbs file in the OneStepFurther folder under Chapter 8.

Chapter 8 Quick Reference

To

Do This

Find the default WMI namespace on a computer

Use the Advanced tab from the WMI Control tool

Find WMI classes on a computer

Use the WMI Object Browser Tool

Make a connection into WMI

Use the WMI moniker in your script

Use a shortcut name for the local computer

Use a "." and assign it to the variable holding the computer name in the script

Find detailed information about all WMI classes on a computer

Use the Platform SDK

Iterate through a collection of objects returned by the ExecQuery method of the SWbemServices object

Use For...Each...Next

List all the namespaces on a computer

Query instances of __NameSpace

List all providers installed in a particular namespace

Query instances of __Win32Provider

List all the classes in a particular namespace on a computer

Use the SubclassesOf() method from the SwbemServices object



Previous Page
Next Page