4. Automating Installation
To achieve a fully automated deployment process, the packages you install must support unattended installation. Many setup programs support /s or /q command-line options for silent or quiet installations; others don't.
Often you can find out if the package supports unattended installation by typing setup /? at the command prompt, where setup
is the file name of the setup program. If the setup program doesn't
provide clues, you need to know which vendor's product was used to
create the package. You can usually tell by running the setup program
and looking for logos, for example, or checking the file properties.
Armed with that information, read the following sections to learn how to
install packages created by different packaging software automatically.
Table 1 summarizes the necessary commands.
Table 1. Unattended Package Installation
PACKAGE TYPE | COMMAND FOR UNATTENDED INSTALLATION |
---|
Windows Installer | msiexec.exe /i package.msi /qn ALLUSERS=2 |
InstallShield Windows Installer | setup.exe /s /v"/qn"
Optionally, you can extract the Windows Installer database from the compressed file and use the command msiexec.exe /i setup.msi ISSETUPDRIVEN=1 /qn to install it. |
Legacy InstallShield | setup.exe /s /sms
To create the Setup.iss file necessary to run setup silently, type setup.exe /r
to create a Setup.iss from your responses to the setup program's dialog
boxes and then copy Setup.iss from %SystemRoot% to the folder
containing the package. |
Legacy InstallShield PackageForTheWeb | setup.exe /a /s /sms
To create the Setup.iss file necessary to run setup silently, type setup.exe /a /r to create the Setup.iss based on your responses and then copy Setup.iss from %SystemRoot% to the folder containing the package. |
Legacy Wise Installation System | setup.exe /s |
Windows
Installer is an installation and configuration service that helps
reduce ownership costs by providing a component-based application
installation architecture. Installation is consistent across all
applications packaged for Windows Installer. Packages are easily
customizable, installations are protected from errors, and a rollback
mechanism provides for recovery in case of failure. Windows
Installer supports application and feature advertising. Windows
Installer provides many other benefits, and most Independent Software
Vendors (ISVs) are now using it to package their applications. Windows 7
includes Windows Installer 5.0. For more information about its new
features, see http://msdn.microsoft.com/en-us/library/aa372796.aspx.
Windows
Installer 5.0 is compatible with User Account Control (UAC) in Windows
7. By using elevated installation, an administrator can authorize
Windows Installer to install applications or security updates on behalf
of users who aren't members of the Administrators group.
Windows Installer packages provide the following to enable flexible application deployment:
Command-line options
You use command-line options to specify options, file names, and path
names, as well as control the action of the installation at run time.
Properties (variables) on the command line Properties are variables that Windows Installer uses during an installation. You can set a subset of these, called public properties, on the command line.
Transforms A transform is a collection of changes you can apply to a base Windows Installer package (.msi) file. You can customize applications
by using Windows Installer transform (.mst) files. You configure
transforms to modify a Windows Installer package to dynamically affect
installation behavior according to your requirements. You associate
transforms with a Windows Installer package at deployment time.
Transforms for Windows Installer package files are similar to answer
files that you might have used to automate the installation of an
operating system such as Windows Vista.
The number
of applications packaged as Windows Installer databases is multiplying
rapidly. Nearly all software vendors are packaging their applications
using this technology. And what often looks like a self-contained,
self-extracting setup program with a file name such as Setup.exe is
often a file that decompresses to a Windows Installer database. You can
usually extract the database by using a tool such as WinZip (from WinZip
Computing at http://www.winzip.com)
or by running the setup program and looking in %UserProfile%\Local
Settings\Temp for the package file. Windows Installer databases have the
.msi file extension.
To install Windows Installer databases unattended using Msiexec.exe, use the /qb command-line option for a basic user interface or the /qn command-line option for no user interface. Also, to ensure that the package installs for all users, add the ALLUSERS=2 property. For example, the command
msiexec.exe /i program
.msi /qn ALLUSERS=2
installs the package file Program.msi with no user interaction and for use by all users who share the computer.
Some Windows Installer databases that Macrovision InstallShield (http://www.acresso.com/products/is/installshield-overview.htm)
creates require that you install them by running Setup.exe. Trying to
install the .msi file using Msiexec.exe results in a message that you
must run Setup.exe to start the installation. When the developer uses
InstallShield Script, this requirement is enforced to ensure that the
needed version of the InstallShield Script Engine (ISScript.msi) is
installed on the computer before proceeding. If it is not detected, the
required version of InstallShield Script Engine is installed
automatically before starting Windows Installer. You can automate this installation a couple of ways:
Use InstallShield's
command-line support that Setup.exe offers. Not only does Setup.exe
provide command-line option support, but you may also pass options to
the Windows Installer setup database by using the /v command-line option. Following /v,
you may specify any options you want to pass to the Windows Installer
setup database within double quotation marks. For example, the following
command installs the application silently and passes the /qn option.
setup.exe /s /v"/qn"
Deploy
the InstallShield Script Engine separately as part of your core
applications before any setup files that require it. You may then safely
bypass running Setup.exe by installing the Windows Installer setup
database with Msiexec.exe and including the ISSETUPDRIVEN
public property. You can extract the embedded Windows Installer setup
database by looking in the %Temp% folder after the welcome message for
the installation wizard is displayed. Then, use the following command to
install it.
msiexec.exe /i setup.msi ISSETUPDRIVEN=1 /qn
Packages
created using legacy InstallShield technologies usually have the file
name Setup.exe. To create an unattended installation for a legacy
InstallShield package, you need to create an InstallShield script, which
has the .iss file extension. Many applications come with such a file,
but they are also easy to create.
To create an InstallShield response file, perform the following steps:
Run the setup program using the /r command-line option. This creates a Setup.iss
file based on how you configure the installation as you step through
the setup program. The result is the file Setup.iss in %SystemRoot%.
Copy Setup.iss from %SystemRoot% to the folder containing the package.
Run the setup program using the /s command-line option. The setup program runs silently using the responses provided by the Setup.iss file.
Note
IMPORTANT
Packages created by InstallShield will spawn a separate process and
then return immediately to the calling program. This means that the
setup program runs asynchronously, even if you start the setup program
using start /wait. You can add the /sms
command-line option to force the setup program to pause until
installation is finished, however, making the process synchronous.
Legacy InstallShield PackageForTheWeb
PackageForTheWeb
is an InstallShield-packaged application contained in a self-contained,
self-extracting file. You create a Setup.iss file and use it in almost
the same way as described in the previous section. The difference is
that you must use the /a
command-line option to pass the command-line options to the setup
program after the file extracts its contents. For example, a file that
you downloaded called Prog.exe will expand its contents into the
temporary folder and then run Setup.exe when finished. To pass
command-line options to Setup.exe, you must use the /a command-line option. The following procedure demonstrates how this extra option changes the steps.
To create an InstallShield PackageForTheWeb response file, perform the following steps:
Run the setup program using the /a /r command-line options: Type setup.exe /a /r. This creates a Setup.iss file based on the way you configure the installation as you step through the setup program. The Setup.iss file is in %SystemRoot%.
Copy Setup.iss from %SystemRoot% to the folder containing the package.
Run the setup program using the /a /s command-line options: Type setup.exe /a /s. The setup program runs silently using the responses in the Setup.iss file.
Legacy Wise Installation System
Packages created using the legacy Wise Installation System recognize the /s command-line option for unattended installation. No tool is available to script the installation, however.
Some
applications cannot be automated with command-line options. These
applications might provide a wizard-based setup routine but require the
user to click buttons or press keys on the keyboard to install the
application. If a user can complete the installation by using only the
keyboard, you can automate the installation by creating a script (a
series of text commands) that simulates keystrokes. This technique is
called screen scraping.
You can screen scrape by using Windows Script Host. Specifically, you use the SendKeys() method to send keystrokes to an application. For more information about the SendKeys() method and an example that you can use to quickly create your own screen-scraping scripts, see http://windowssdk.msdn.microsoft.com/en-us/library/8c6yea83.aspx.
Note
ON THE COMPANION MEDIA The companion media contains the sample script Sendkeys.vbs, which provides a shell for using the SendKeys() method without having to write your own script. It accepts two command-line options: sendkeys.vbs program textfile, where program is the path and file name of the program you want to drive, and textfile is the path and file name of the text file containing the keystrokes, one keystroke per line, to send to the program. See http://windowssdk.msdn.microsoft.com/en-us/library/8c6yea83.aspx for a list of key codes. If you need to pause before sending more keystrokes, add a line to the file that contains sleep. Each line that contains sleep will pause for 1 second. The file Sendkeys.txt is a sample textfile you can use with Sendkeys.vbs; for example, type sendkeys.vbs notepad.exe sendkeys.txt and watch what happens.