Enumerating Installed Software Features

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Because much of the software developed today allows the user to choose which features to install, enumerating only the software packages might not provide a complete picture of the software installed on that computer. To obtain more detailed information about the software installed on a computer, you might need to enumerate the installed features of each software package, including such things as a dictionary, clip art, and design templates.

You can retrieve a list of software features by using the Win32_SoftwareFeature class. Some of the primary properties of this class are listed in Table 8.15.

Table 8.15   Win32_SoftwareFeature Properties

PropertyDescription
AccessesNumber of times the software feature has been used.
AttributesFeature execution option. Values include:

0 Install components locally if possible.

1 Install components to run from the source CD/server if possible.

2 Follow the remote execution option of the parent feature.

CaptionShort textual description of the object.
DescriptionTextual description of the object. In practice, this will often return the same value as Caption.
IdentifyingNumberProduct identification, such as a serial number.
InstallDateDate the feature was installed.
InstallStateInstalled state of the product. Values include:

6 Bad configuration

2 Invalid argument

1 Unknown package

1 Advertised

2 Absent

3 Local

4 Source

LastUseDate and time the software feature was last used. If the application has never been used, this date will typically be January 1, 1980.
NameLabel by which the object is known.
ProductNameCommonly used product name.
VendorName of the product's supplier.
VersionProduct version information.

Scripting Steps

Listing 8.13 contains a script that enumerates the software features installed on a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.
  2. Use a GetObject call to connect to the WMI namespace root\cimv2, and set the impersonation level to "impersonate."
  3. Use the ExecQuery method to query the Win32_SoftwareFeature class.

    This query returns a collection consisting of all the software features for all the software products installed on the computer.

  4. For each feature in the collection, echo the appropriate properties.

Listing 8.13   Enumerating Installed Software Features

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 
strComputer = "." Set objWMIService = GetObject("winmgmts:" _     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFeatures = objWMIService.ExecQuery _     ("SELECT * FROM Win32_SoftwareFeature") For each objFeature in colFeatures     Wscript.Echo "Accesses: " & objFeature.Accesses     Wscript.Echo "Attributes: " & objFeature.Attributes     Wscript.Echo "Caption: " & objFeature.Caption     Wscript.Echo "Description: " & objFeature.Description     Wscript.Echo "Identifying Number: " & objFeature.IdentifyingNumber     Wscript.Echo "Install Date: " & objFeature.InstallDate     Wscript.Echo "Install State: " & objFeature.InstallState     Wscript.Echo "Last Use: " & objFeature.LastUse     Wscript.Echo "Name: " & objFeature.Name     Wscript.Echo "Product Name: " & objFeature.ProductName     Wscript.Echo "Vendor: " & objFeature.Vendor     Wscript.Echo "Version: " & objFeature.Version Next

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net