Microsoft KB Archive/891753

= How to install a Windows Installer package from a Windows Management Instrumentation (WMI) script =

Article ID: 891753

Article Last Modified on 3/14/2007

-

APPLIES TO


 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Web Edition
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition

-





INTRODUCTION
This article describes how to install a Microsoft Windows Installer package from a Microsoft Windows Management Instrumentation (WMI) script.



MORE INFORMATION
The WMI Win32_Product class represents products as they are installed by Windows Installer. Calling the Install method of the Win32_Product class installs an associated Win32_Product instance by using the installation package that is provided through the PackageLocation parameter and any command-line options that are supplied. The Install method takes the following parameters as inputs:
 * The PackageLocation parameter specifies the path of the Windows Installer package. This path is relative to the computer on which the software is being installed and which can be referenced by using a Universal Naming Convention (UNC) path.
 * The Options parameter specifies the command-line options that are required for installing the software. If no options are required, this parameter should be left blank.
 * The AllUsers parameter specifies a Boolean value that indicates whether the software should be available to all the users on a computer or to just the currently logged-on user.

Note If the AllUsers parameter is set to true, the software is installed under the All Users profile. If the AllUsers parameter is set to false, the software is installed under the profile of the user whose credentials are being used to run the script. For example, if the script is run under the Administrators account, the software is installed under the Administrators profile. Therefore, other users cannot access the software.

To install a Windows Installer package from a WMI script, follow these steps:  Start Notepad.  Copy the following Microsoft Visual Basic code, and then paste this code into Notepad. Const ALL_USERS = True Set objService = GetObject(&quot;winmgmts:&quot;) Set objSoftware = objService.Get(&quot;Win32_Product&quot;) errReturn = objSoftware.Install(&quot;&quot;,, ALL_USERS) Note In this code,  is the name of the Windows Installer package.  Save the file by using the .vbs file name extension. For example, save the file as c:\scripts\installdb.vbs. Click Start, click Run, type c:\scripts\installdb.vbs in the Open box, and then click OK.

