|
Back in the third article in this series, we developed the following simple script named displayTimeZone.vbs that displays the current time zone setting on your machine: Option Explicit On Error Resume Next Dim strComputer Dim strWMINamespace Dim strWMIQuery Dim objWMIService Dim colItems Dim objItem strComputer = "." strWMINamespace = "\root\CIMV2" strWMIQuery = "SELECT * FROM Win32_TimeZone" Set objWMIService = GetObject("winmgmts:\\" & strComputer & strWMINamespace) Set colItems = objWMIService.ExecQuery(strWMIQuery) For Each objItem In colItems WScript.Echo objItem.Caption Next When I run this script, I get the following result: C:\scripts>DisplayTimeZone.vbs Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. (GMT-06:00) Central Time (US & Canada) How did I know that it was the Caption property of the Win32_TimeZone class that contains the information I want to display? By reading the description of the Win32_TimeZone WMI class on MSDN. In fact, this MSDN page tells us that the Description property basically returns the same information as the Caption property, so I could have changed the line WScript.Echo objItem.Caption to WScript.Echo objItem.Description and gotten the same result. |