Chapter 3
Scripting Installations and
Updates
This chapter is excerpted from Windows Admin Scripting Little Black
Book, 3rd Edition, by Jesse M. Torres [ISBN: 1-933097-10-8]. Copyright
(c) 2006, Paraglyph Press. Reprinted with permission.
All rights reserved.
Presented by
Chapter 3
Scripting Installations
and Updates
If you need an immediate solution to: See page:
Scripting a Silent .NET Framework Installation 46
Scripting a Silent MDACS Installation 46
Scripting a Silent Windows 2000/XP Service Pack Installation 47
Scripting an Internet Explorer Download 47
Scripting a Silent Internet Explorer Install 48
Scripting a Silent WinZip Installation 48
Scripting a Silent RealVNC Installation 49
Scripting a Silent Windows Media Player Installation 50
Scripting a Silent DirectX Installation 50
Working with the Windows Installer 51
Scripting a Silent Acrobat Reader Install 51
Scripting a QuickTime Install 51
Scripting a Silent pcANYWHERE Installation 52
Scripting a Silent Windows 2000 Resource Kit Installation 52
Scripting the Windows Installer Installation 53
Scripting Microsoft Office 2000/XP 53
Disabling Windows Installer Rollbacks 55
Installing the Windows Installer Clean Up Utility 55
39
Chapter 3 Scripting Installations and Updates
In Brief
In the previous chapter, you learned how to automate hard disk set-
ups and images. Throughout this chapter, you will use various script-
ing methods to create unique scripting solutions to common
administrative installations and updates. You will start by learning
3. Scripting Installations
how to script installations from the command line. You will then learn
how to use send keys to install windows and wizards using AutoIt.
and Updates
Scripting Methods
Not all of us have the luxury of working with a centralized manage-
ment system such as Systems Management Server (SMS) Lan Desk,
or Tivoli. With new programs, program updates, service pack updates,
and hot-fixes constantly coming out, installing all of these manually
can consume most of an administrator’s day. Scripting provides a way
to automate these tasks with little or no user intervention.
40
In Brief
3. Scripting Installations
• /R:S—Reboots without prompting
• /T:path—Specifies or extracts files to a temporary working
and Updates
folder
• /U—Runs in unattended mode or uninstalls an application,
prompts for shared file removal
• /UA—Uninstalls an application and shared files, without prompting
• /Z—Does not reboot when installation is complete
41
Chapter 3 Scripting Installations and Updates
For example, suppose you wanted to script the Add New Hardware
3. Scripting Installations
Wizard window (see Figure 3.1). Running the utility would show the
window title and text (see Figure 3.2).
and Updates
42
In Brief
3. Scripting Installations
and Updates
Figure 3.2 Detecting window title and text with /REVEAL.
NOTE: For more information and details on usage, see the AutoItX3 control documentation
included in the program install.
43
Chapter 3 Scripting Installations and Updates
The installation service enables the system to keep track of all pro-
gram installations and system changes, providing for cleaner
uninstalls. Because the installation service runs as a system service,
it can be given various privileges to allow users to install their own
applications.
Self-Repair
When a program file becomes corrupted or missing, a program
installed with the Windows Installer can identify these files and
replace them automatically. This is a handy feature for those of us
with troublesome users who like to attempt their own uninstalls.
Rollback
The Windows Installer rollback feature creates a temporary backup
and script of any files changed during the installation process. If a
fatal error occurs during the installation, the rollback feature
immediately runs the script and returns the system to its original
state. All rollback files are stored in a temporary file called config.msi,
44
In Brief
TIP: You can always delete the config.msi file manually if setup fails to remove it.
3. Scripting Installations
ing you to control the installer from the command shell or batch file.
Here are some of the most common command-line switches for
and Updates
Microsoft Windows Installer:
• /I—Installs the program
• /F—Repairs an installation
• /X—Uninstalls the program
• /L*V logfile—Logs all information to a logfile
• /QN—No user interface
• /QB—Basic user interface
• /QF—Full user interface
• /? or /H—Displays some switches and copyright information
• /X—Uninstalls the program
A Word of Caution
This chapter contains many scripting examples on performing appli-
cation installs and uninstalls. An improper installation/uninstallation
may not only leave the application inoperable, but other applications
and even the operating system could be harmed as well. As with all
scripts, you should first test the script in an isolated testing environ-
ment to ensure the script produces the desired results before using it
in a production environment.
45
Chapter 3 Scripting Installations and Updates
Immediate Solutions
Installation
and Updates
Here, new directory path is the complete path of the new folder
created in step 1.
46
Immediate Solutions
Here, new directory path is the complete path of the new folder
created in step 1, and executable is the name of the MDACS execut-
able downloaded in step 2.
3. Scripting Installations
Pack Installation
and Updates
The Windows 2000/XP service packs allow you to script an install
without forcing you to extract the files first. To automate a silent in-
stallation of a Windows 2000/XP service pack, proceed as follows:
1. Create a new directory to store all files included in this example.
2. Download the latest service pack, from www.microsoft.com,
to the new directory.
3. Start the command prompt and enter the following:
Here, new directory path is the complete path of the new folder
created in step 1, and executable is the name of the service pack
executable downloaded in step 2.
47
Chapter 3 Scripting Installations and Updates
Here, new directory path is the complete path of the new folder
created in step 1.
Here, new directory path is the complete path of the new folder
created in step 1.
48
Immediate Solutions
Run("WinZipInstallationExecutable.exe")
3. Scripting Installations
WinWaitActive("WinZip Setup", "Setup will install WinZip into
the following folder")
and Updates
Send("{ENTER}")
WinWaitActive("License Agreement")
Send("!y")
WinWaitActive("WinZip (")
WinClose("WinZip (")
49
Chapter 3 Scripting Installations and Updates
Here, new directory path is the complete path of the new folder
created in step 1.
Here, new directory path is the complete path of the new folder
created in step 1.
50
Immediate Solutions
3. Scripting Installations
Here, new directory path is the complete path of the new folder
created in step 1.
and Updates
Working with the Windows Installer
The Windows Installer replaces the old ACME installer, adding more
features and functionality. This new installer provides a standard
method for application installations and an easy way for administra-
tors to script installations.
Here, new directory path is the complete path of the new folder
created in step 1.
51
Chapter 3 Scripting Installations and Updates
Here, new directory path is the complete path of the new folder
3. Scripting Installations
created in step 1.
and Updates
Here, file path is the complete path of the pcANYWHERE 11.5 in-
stallation files.
NOTE: Using the /QB switch may cause the installer to prompt that it is uninstalling the resource
kit when in fact it is installing it.
TIP: You can script a silent Microsoft TechNet installation using the same install syntax and
replacing the name of the msi file.
52
Immediate Solutions
3. Scripting Installations
instmsi.htm.
and Updates
3. Select Start|Run and enter “new directory path\wiexe /Q:A /
R:A.”
Here, new directory path is the complete path of the new folder
created in step 1, and wiexe is the name of the Windows Installer
redistributable executable.
NOTE: The Microsoft Office Removal Wizard is included in the Microsoft Office 2000/XP
Resource Kit.
53
Chapter 3 Scripting Installations and Updates
Here, file path is the complete path of the Office installation files,
install log is the file to store all errors and output, and company is
the name of the company registered for Office.
TIP: For more information about Office 2000/XP command-line switches, see the Microsoft
TechNet Article Q202946 (Office 2000) and Q283686 (Office XP).
3. Scripting Installations
Scripting an Uninstall
To automate the uninstallation of Microsoft Office 2000/XP, start the
and Updates
Here, file path is the complete path of the Office installation files
originally used to install Office, and msifile is the name of the msi
package to uninstall.
Scripting a Repair
To automate the repair of a Microsoft Office 2000/XP installation, start
the command prompt and enter the following:
Here, file path is the complete path of the Office installation files
originally used to install Office, and msifile is the name of the msi
package to repair.
Scripting a Reinstallation
To automate the reinstallation of Microsoft Office 2000/XP, start the
command prompt and enter the following:
Here, file path is the complete path of the Office installation files
originally used to install Office, and msifile is the name of the msi
package to reinstall.
Advertising
Instead of installing an application, you can simply set up the Start
menu shortcuts that, when activated, will install the application on
first use. This setup method is called advertising. To advertise
54
Immediate Solutions
Microsoft Office 2000/XP, start the command prompt and enter the
following:
Here, file path is the complete path of the Office installation files
originally used to install Office, and msifile is the name of the msi
package to advertise.
3. Scripting Installations
To disable the Windows Installer Rollback feature during an installa-
tion, start the command prompt and enter the following:
and Updates
file path\SETUP DISABLEROLLBACK=1
Here, file path is the complete path of the installation files used in
the original installation.
download.microsoft.com/download/office2000pro/util22/1/W9X/
EN-US/msicu.exe
download.microsoft.com/download/office2000pro/util20/1/NT4/
EN-US/msicuu.exe
55
Chapter 3 Scripting Installations and Updates
AdlibEnable("AdlibHandler")
RUN("executable")
3. Scripting Installations
Exit
Func AdlibHandler()
;Used to prevent installation from unexpectedly ending
If WinActive("Windows Installer", "Setup is not complete") Then
WinActivate("Windows Installer", "Setup is not complete")
Send("!R")
EndIf
If WinActive("Windows Installer", "Windows Installer Clean Up
was interrupted") Then
WinActivate("Windows Installer", "Windows Installer Clean Up
was interrupted")
Send("{ENTER}")
EndIf
3. Scripting Installations
EndFunc
and Updates
Here, executable is the name of the Windows Installer Clean Up ex-
ecutable.
NOTE: For more information about the Windows Installer Clean Up utility, see the Microsoft
TechNet article Q238413 (Office 2000) and Q290301 (Office XP).
57