Export (0) Print
Expand All

Install method of the Win32_Product class

The static Install WMI class method installs an associated Win32_Product instance using the installation package provided through the PackageLocation parameter, and any supplied command line options.

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

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax


uint32 Install(
  [in]  string PackageLocation,
  [in]  string Options,
  [in]  boolean AllUsers
);

Parameters

PackageLocation [in]

Path to the Installer package, which is relative to the computer on which the software is being installed and which can be referenced using a Universal Naming Convention (UNC) path.

Options [in]

Command-line options required for installing the software. Format as property=setting. If no options are required, this parameter should be left blank.

AllUsers [in]

Boolean value that indicates whether the software should be available to all the users on a computer or just the currently logged-on user. If True, the software will be installed under the All Users profile. If set to False, the software will be installed under the profile of the user whose credentials are being used to run the script. For example, if the script is running under the Administrator account, the software will be installed under the Administrator profile and thus will not be accessible to other users.

Return value

Return codeDescription
0

Successful completion

13

The data is invalid.

87

One of the parameters was invalid.

120

This value is returned when a custom action attempts to call a function that cannot be called from custom actions. The function returns the value ERROR_CALL_NOT_IMPLEMENTED. Available beginning with Windows Installer version 3.0.

1259

This error code only occurs when using Windows Installer version 2.0 and Windows XP. If Windows Installer determines a product may be incompatible with the current operating system, it displays a dialog box informing the user and asking whether to try to install anyway. This error code is returned if the user chooses not to try the installation.

1601

The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered.

1602

The user cancels the installation.

1603

A fatal error occurred during the installation.

1604

Installation suspended, incomplete.

1605

This action is only valid for products that are currently installed.

1606

The feature identifier is not registered.

1607

The component identifier is not registered.

1608

This is an unknown property.

1609

The handle is in an invalid state.

1610

The configuration data for this product is corrupt. Contact your support personnel.

1611

The component qualifier is not present.

1612

The installation source for this product is not available. Verify that the source exists and that you can access it.

1613

This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.

1614

The product is un-installed.

1615

The SQL query syntax is invalid or unsupported.

1616

The record field does not exist.

1618

Another installation is already in progress. Complete that installation before proceeding with this install.

1619

This installation package could not be opened. Verify that the package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer package.

1620

This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package.

1621

There was an error when starting the Windows Installer service user interface. Contact your support personnel.

1622

There was an error opening installation log file. Verify that the specified log file location exists and is writable.

1623

This language of this installation package is not supported by your system.

1624

There was an error applying transforms. Verify that the specified transform paths are valid.

1625

This installation is forbidden by system policy. Contact your system administrator.

1626

The function could not be executed.

1627

The function failed during execution.

1628

An invalid or unknown table was specified.

1629

The data supplied is the wrong type.

1630

Data of this type is not supported.

1631

The Windows Installer service failed to start. Contact your support personnel.

1632

The Temp folder is either full or inaccessible. Verify that the Temp folder exists and that you can write to it.

1633

This installation package is not supported on this platform. Contact your application vendor.

1634

Component is not used on this machine.

1635

This patch package could not be opened. Verify that the patch package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer patch package.

1636

This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package.

1637

This patch package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.

1638

Another version of this product is already installed. Installation of this version cannot continue.

1639

Invalid command line argument. Consult the Windows Installer SDK for detailed command-line help.

1640

Installation from a Terminal Server client session is not permitted for the current user.

1641

The installer has initiated a restart. This message is indicative of a success. This error code is not available on Windows Installer version 1.0.

1642

The installer cannot install the upgrade patch because the program being upgraded may be missing or the upgrade patch updates a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch. This error code is not available on Windows Installer version 1.0.

1643

The patch package is not permitted by system policy. This error code is available with Windows Installer version 2.0.

1644

One or more customizations are not permitted by system policy. This error code is available with Windows Installer version 2.0.

1645

Windows Installer does not permit installation from a Remote Desktop Connection. Available beginning with Windows Installer version 2.0 for Windows Server 2003.

1646

The patch package is not a removable patch package. Available beginning with Windows Installer version 3.0.

1647

The patch is not applied to this product. Available beginning with Windows Installer version 3.0.

1648

No valid sequence could be found for the set of patches. Available beginning with Windows Installer version 3.0.

1649

Patch removal was disallowed by policy. Available beginning with Windows Installer version 3.0.

1650

The XML patch data is invalid. Available beginning with Windows Installer version 3.0.

1651

Administrative user failed to apply patch for a per-user managed or a per-machine application that is in advertise state. Available beginning with Windows Installer version 3.0.

3010

A restart is required to complete the install. This message is indicative of a success. This does not include installs where the ForceReboot action is run. This error code is not available on Windows Installer version 1.0.

2147549445

RPC Server Fault Error

 

Remarks

The ability to install software without using Group Policy can be an enormous boon to administrators; this allows you to install software without requiring user interaction and without requiring the user to log off and log on or the computer to restart. In addition, a WMI script can help ensure a successful installation by doing such things as checking for available memory or available disk space before beginning the installation process. If there is not enough memory or disk space on the target computer, your script can terminate without installing the software. This prevents any problems that can occur from attempting to install software on computers not capable of running that software.

The install method of Win32_Product can be used to install software on the local or remote computer.

Examples

The following VBScript sample installs software for all users on a local computer.

Const ALL_USERS = True
Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install("c:\scripts\database.msi", , ALL_USERS)

The following VBScript sample installs software for all users on a remote computer.

strComputer = "atl-dc-02"
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objSoftware = objWMIService.Get("Win32_Product")
errReturn = objSoftware.Install("c:\scripts\database.msi",,True)
Wscript.Echo errReturn

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
Win32_Product
WMI Tasks: Computer Software

 

 

Community Additions

ADD
Show:
© 2014 Microsoft