Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Knowing the software packages that have been installed on a computer is useful for many reasons. Among other things, this knowledge helps you:
These activities cannot be carried out using Group Policy because the Software Installation and Maintenance component does not provide information on the software installed on a computer; it only makes that software available for installation. For example, although the Software Installation and Maintenance component can publish a software package, it provides no way to track which users install that package. This makes it difficult to analyze actual software use or to make projections for future software needs.
The WMI Win32_Product class enables you to enumerate the software installed on a computer, provided the software was installed by using the Windows Installer. Selected properties available through the Win32_Product class are shown in Table 8.14.
Table 8.14 Win32_Product Properties
Property | Description |
---|---|
Caption | Short description of the object. |
Description | Object description. |
IdentifyingNumber | Product identification, such as a serial number on software. |
InstallLocation | Location of the installed product. |
InstallState | Installed state of the product. Values include: 6 Bad configuration 2 Invalid argument 1 Unknown package 1 Advertised 2 Absent 6 Installed |
Name | Commonly used product name. |
PackageCache | Location of the locally cached package for this product. |
SKUNumber | Product SKU (stock-keeping unit) information. |
Vendor | Name of the product's supplier. |
Version | Product version information. |
Listing 8.12 contains a script that enumerates the software installed on a computer and then saves the information to a text file. To carry out this task, the script must perform the following steps:
This object will be used to write the retrieved software information to a text file.
The VBScript constant VbTab is used to insert a tab character between each field header. The tab-separated-values format is used because software property values sometimes contain commas. If they do, these extra commas can make it difficult to parse a text file saved in comma-separated-values format.
This query returns a collection consisting of all the software products installed on the computer.
Listing 8.12 Enumerating Installed Software
|
|
Send us your feedback | « Previous | Next » |