1. Home
  2. Computing & Technology
  3. Visual Basic

VBScript - The System Administrator's Language - Part 2

By Dan Mabbutt, About.com

6 of 7

Finding the Actual Names in WMI and Running the Script

Getting Object Names From wbemtest

Getting Object Names From wbemtest

I mentioned earlier that only the items displayed in bold type need to be changed to make this script work. Let's see what they are.

First, strComputerName can be defaulted to ".". This points to your local machine. That was easy! The next one, WMI_ProcessName, will take a little more checking. Checking wbemtest, we find something called Win32_PnPSignedDriver which looks like a likely candidate. To discover the ItemPropertyName values, the wbemtest utility tells us that we can get the properties Description, DeviceName, Manufacturer, and DriverVersion. The screenshot shows the last property, DriverVersion, displayed in wbemtest.

The script now looks like this (with a few extra statements to complete it).

Use this command in a DOS Command Window to run your script:

cscript scriptname.vbs where scriptname is replaced by the name you used.

~~~~~~~~~~~~~~~~~~~~~~~~~
strComputer = "."
Set objWMIService = _
  GetObject( _
  "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = _
  objWMIService.ExecQuery( _
  "Select * from Win32_PnPSignedDriver")
For Each objItem in colItems
  Wscript.Echo "Description: " & objItem.Description
  Wscript.Echo "DeviceName: " & objItem.DeviceName
  Wscript.Echo "Manufacturer: " & objItem.Manufacturer
  Wscript.Echo "DriverVersion: " & objItem.DriverVersion
  Wscript.Echo " "
Next
~~~~~~~~~~~~~~~~~~~~~~~~~

Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB 6
  5. Learn VBScript
  6. VBScript - The System Administrator's Language - Part 2

©2009 About.com, a part of The New York Times Company.

All rights reserved.