Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003

Microsoft® Windows® 2000 Scripting Guide

« Previous | Next »   

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 Win32_Product class includes an Install method that can be used to install software on the local computer. (In other words, the script physically resides on the computer where the software will be installed.) Software can also be installed on remote computers; however, because remote installation might require some additional configuration, the remote installation process is discussed in the next section of this chapter.

Regardless of whether the software is installed locally or remotely, the Install method requires three parameters:

Scripting Steps

Listing 8.14 contains a script that installs software for all users on a computer. To carry out this task, the script must perform the following steps:

  1. Create a constant ALL_USERS and assign it the value True. This constant is used to install the software in the All Users profile.
  2. Use a GetObject call to connect to the WMI service.
  3. Retrieve an instance of the Win32_Product class.
  4. Use the Install method to install the Windows Installer package. This method requires the following three parameters:
    • C:\Scripts\Database.msi The location of the software package being installed
    • Null Indicates that no command-line options are required to install the product
    • ALL_USERS Constant (with the value True) that installs the software under the All Users profile

Listing 8.14   Installing Software

1 2 3 4

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


 Send us your feedback « Previous | Next »   

Категории