共用方式為


Win32_Product class

The Win32_Product WMI class represents products as they are installed by Windows Installer. A product generally correlates to one installation package.

Note  For more information about support or requirements for installation of a specific operating system, see Operating System Availability of WMI Components.

 

The following syntax is simplified from Managed Object Format (MOF) code and includes all inherited properties. Properties and methods are in alphabetic order, not MOF order.

Syntax

[Provider("MSIProv"), Dynamic]
class Win32_Product : CIM_Product
{
  uint16   AssignmentType;
  string   Caption;
  string   Description;
  string   IdentifyingNumber;
  string   InstallDate;
  datetime InstallDate2;
  string   InstallLocation;
  sint16   InstallState;
  string   HelpLink;
  string   HelpTelephone;
  string   InstallSource;
  string   Language;
  string   LocalPackage;
  string   Name;
  string   PackageCache;
  string   PackageCode;
  string   PackageName;
  string   ProductID;
  string   RegOwner;
  string   RegCompany;
  string   SKUNumber;
  string   Transforms;
  string   URLInfoAbout;
  string   URLUpdateInfo;
  string   Vendor;
  uint32   WordCount;
  string   Version;
};

Members

The Win32_Product class has these types of members:

  • Methods
  • Properties

Methods

The Win32_Product class has these methods.

Method Description
Admin

Performs an administrative install of an associated Win32_Product instance using the installation package provided through PackageLocation, and any command line options that are supplied.

Advertise

Advertises an associated Win32_Product instance using the installation package provided through PackageLocation and any command line options that are supplied.

Configure

Configures the associated instance of Win32_Product to the specified install state and level.

Install

Installs an associated Win32_Product instance using the installation package provided through PackageLocation and any command line options that are supplied.

Reinstall

Reinstalls the associated instance of Win32_Product using the specified reinstallation mode.

Uninstall

Uninstalls the associated instance of Win32_Product.

Upgrade

Upgrades the associated Win32_Product instance using the upgrade package provided through PackageLocation and any command line options that are supplied.

 

Properties

The Win32_Product class has these properties.

AssignmentType

Data type: uint16

Access type: Read-only

Assignment type of the product.

Windows Server 2003: This property is not available.

Possible values are

Value Meaning
0

The product is assigned by user.

1

The product is assigned by computer.

 

Caption

Data type: string

Access type: Read-only

Short textual description for the product—a one-line string.

Description

Data type: string

Access type: Read-only

Description of the product.

HelpLink

Data type: string

Access type: Read-only

The support link for the product.

Windows Server 2003: This property is not available.

HelpTelephone

Data type: string

Access type: Read-only

The support telephone for the product.

Windows Server 2003: This property is not available.

IdentifyingNumber

Data type: string

Access type: Read-only

Product identification such as a serial number on software, or a die number on a hardware chip.

InstallDate

Data type: string

Access type: Read-only

This property is no longer supported for Win32_Product. Instead, use the InstallDate2 property, which is in the WMI CIM_DATETIME format.

InstallDate2

Data type: datetime

Access type: Read-only

Date that this product was installed on the system. This property does not require a value to indicate that the object is installed. For more information about WMI dates and times, see Date and Time Format.

InstallLocation

Data type: string

Access type: Read-only

Location of the installed product.

InstallSource

Data type: string

Access type: Read-only

The installation source directory of the product.

Windows Server 2003: This property is not available.

InstallState

Data type: sint16

Access type: Read-only

Installed state of the product.

Value Meaning
-6

Bad Configuration

-2

Invalid Argument

-1

Unknown Package

1

Advertised

2

Absent

5

Installed

 

Language

Data type: string

Access type: Read-only

The language of the product.

Windows Server 2003: This property is not available.

LocalPackage

Data type: string

Access type: Read-only

The location of the locally cached package for this product.

Windows Server 2003: This property is not available.

Name

Data type: string

Access type: Read-only

Qualifiers: Key, Dynamic

Commonly used product name.

PackageCache

Data type: string

Access type: Read-only

Location of the locally cached package for this product.

PackageCode

Data type: string

Access type: Read-only

The identifier for the package from which this product was installed.

Windows Server 2003: This property is not available.

PackageName

Data type: string

Access type: Read-only

The original package name for the product.

Windows Server 2003: This property is not available.

ProductID

Data type: string

Access type: Read-only

The product ID.

Windows Server 2003: This property is not available.

RegCompany

Data type: string

Access type: Read-only

The company registered to use the product.

Windows Server 2003: This property is not available.

RegOwner

Data type: string

Access type: Read-only

The owner registered to use the product.

Windows Server 2003: This property is not available.

SKUNumber

Data type: string

Access type: Read-only

Product SKU (stock-keeping unit) information.

Transforms

Data type: string

Access type: Read-only

The transforms of the product.

Windows Server 2003: This property is not available.

URLInfoAbout

Data type: string

Access type: Read-only

The URL information for the product.

Windows Server 2003: This property is not available.

URLUpdateInfo

Data type: string

Access type: Read-only

The URL update information the product.

Windows Server 2003: This property is not available.

Vendor

Data type: string

Access type: Read-only

Name of the product supplier. Corresponds to the Vendor property in the product object in the Desktop Management Task Force (DMTF) Solution Exchange Standard.

Version

Data type: string

Access type: Read-only

Product version information. Corresponds to the Version property in the product object in the DMTF Solution Exchange Standard.

WordCount

Data type: uint32

Access type: Read-only

Number of words in the summary information for the product.

Windows Server 2003: This property is not available.

Remarks

The Win32_Product class is derived from CIM_Product.

Knowing the software packages that have been installed on a computer is useful for many reasons. Among other things, this knowledge helps you:

  • Gain insight into what the computer is used for. A computer that does not have a word processor installed is probably not used for writing memos or other documents.
  • Ensuring that only licensed software, and only approved software, is in use in your organization. If your organization has decided to standardize on Microsoft Excel, it is very useful, for both support and legal reasons, to know whether anyone has installed a different spreadsheet program on a computer.
  • Tracking the progress of software deployment projects (for example, the number of people who have installed this new application and the number of people who have not).
  • Planning for future software needs.

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 Win32_Product class enables you to enumerate the software installed on a computer, provided the software was installed by using the Windows Installer.

Warning  Win32_Product is not query optimized. Queries such as "select * from Win32_Product where (name like 'Sniffer%')" require WMI to use the MSI provider to enumerate all of the installed products and then parse the full list sequentially to handle the “where” clause. This process also initiates a consistency check of packages installed, verifying and repairing the install. With an account with only user privileges, as the user account may not have access to quite a few locations, may cause delay in application launch and an event 11708 stating an installation failure. For more information, see KB Article 794524.

 

Examples

The Powershell Remote PC Info Script PowerShell code sample uses a number of hardware and software classes, including Win32_Product, to find various information about a remote PC using WMI and the remote registry.

The List Information About the Binary Files Used by an Application VBScript returns the name and product code of binary information (such as bitmaps, icons, executable files, and so on) used by a Windows Installer application.

The following code example shows how to generate an inventory list of installed software on a local computer. The script generates a text file with a list of the software and versions installed on a local computer.

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & _
    "{impersonationLevel=impersonate}!\\" & _
    strComputer & _
    "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Product")   

If colSoftware.Count > 0 Then

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.CreateTextFile( _
        "c:\SoftwareList.txt", True)

    For Each objSoftware in colSoftware
        objTextFile.WriteLine objSoftware.Caption & vbtab & _
        objSoftware.Version
    Next

    objTextFile.Close

Else
    WScript.Echo "Cannot retrieve software from this computer."

End If

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Namespace

Root\CIMV2

MOF

Msi.mof

DLL

Msiprov.dll

See also

Installed Applications Classes

WMI Tasks: Computer Software

Win32_SoftwareFeature