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 code | Description |
---|---|
|
Successful completion |
|
The data is invalid. |
|
One of the parameters was invalid. |
|
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. |
|
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. |
|
The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered. |
|
The user cancels the installation. |
|
A fatal error occurred during the installation. |
|
Installation suspended, incomplete. |
|
This action is only valid for products that are currently installed. |
|
The feature identifier is not registered. |
|
The component identifier is not registered. |
|
This is an unknown property. |
|
The handle is in an invalid state. |
|
The configuration data for this product is corrupt. Contact your support personnel. |
|
The component qualifier is not present. |
|
The installation source for this product is not available. Verify that the source exists and that you can access it. |
|
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. |
|
The product is un-installed. |
|
The SQL query syntax is invalid or unsupported. |
|
The record field does not exist. |
|
Another installation is already in progress. Complete that installation before proceeding with this install. |
|
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. |
|
This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package. |
|
There was an error when starting the Windows Installer service user interface. Contact your support personnel. |
|
There was an error opening installation log file. Verify that the specified log file location exists and is writable. |
|
This language of this installation package is not supported by your system. |
|
There was an error applying transforms. Verify that the specified transform paths are valid. |
|
This installation is forbidden by system policy. Contact your system administrator. |
|
The function could not be executed. |
|
The function failed during execution. |
|
An invalid or unknown table was specified. |
|
The data supplied is the wrong type. |
|
Data of this type is not supported. |
|
The Windows Installer service failed to start. Contact your support personnel. |
|
The Temp folder is either full or inaccessible. Verify that the Temp folder exists and that you can write to it. |
|
This installation package is not supported on this platform. Contact your application vendor. |
|
Component is not used on this machine. |
|
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. |
|
This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package. |
|
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. |
|
Another version of this product is already installed. Installation of this version cannot continue. |
|
Invalid command line argument. Consult the Windows Installer SDK for detailed command-line help. |
|
Installation from a Terminal Server client session is not permitted for the current user. |
|
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. |
|
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. |
|
The patch package is not permitted by system policy. This error code is available with Windows Installer version 2.0. |
|
One or more customizations are not permitted by system policy. This error code is available with Windows Installer version 2.0. |
|
Windows Installer does not permit installation from a Remote Desktop Connection. Available beginning with Windows Installer version 2.0 for Windows Server 2003. |
|
The patch package is not a removable patch package. Available beginning with Windows Installer version 3.0. |
|
The patch is not applied to this product. Available beginning with Windows Installer version 3.0. |
|
No valid sequence could be found for the set of patches. Available beginning with Windows Installer version 3.0. |
|
Patch removal was disallowed by policy. Available beginning with Windows Installer version 3.0. |
|
The XML patch data is invalid. Available beginning with Windows Installer version 3.0. |
|
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. |
|
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. |
|
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 |
|
DLL |
|