21
Windows Admin Scripting Little Black Book 3rd Edition 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. To learn more about Paraglyph Press, please visit http://paraglyph.oreilly.com/ . Presented by

Windows Admin Scripting 03

Embed Size (px)

Citation preview

Page 1: Windows Admin Scripting 03

Windows Admin Scripting Little Black Book

3rd Edition

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.

To learn more about Paraglyph Press, please visit http://paraglyph.oreilly.com/.

Presented by

Page 2: Windows Admin Scripting 03

Chapter 3

39

Scripting Installationsand 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

Page 3: Windows Admin Scripting 03

40

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

sIn 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 commonadministrative installations and updates. You will start by learninghow to script installations from the command line. You will then learnhow to use send keys to install windows and wizards using AutoIt.

Scripting MethodsNot 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 manuallycan consume most of an administrator’s day. Scripting provides a wayto automate these tasks with little or no user intervention.

Microsoft Command-Line SwitchesMicrosoft installation and update executables support many differ-ent switches to allow for shell scripting and installation customization.Switches are not case-sensitive and, more often than not, they are notstandardized. To make matters worse, Microsoft tends not to docu-ment some of the most useful switches (as you saw in Chapter 2).Here are some of the most common, and possibly undocumented,switches for Microsoft installation and update executables:

• /?—Displays unhidden switches and usage

• /C—Extracts files to folder specified with /T switch

• /C ID—Used to enter a 20-digit product ID

• /F—Forces applications to close at shutdown

• /K ID—Used to enter an 11-digit CD key

• /N—Does not back up files for uninstall

• /N name—Used to enter a username for registration

• /N:V—Installs without version checking

• /O—Overwrites OEM files without prompting

• /O organization—Used to enter an organization name forregistration

Page 4: Windows Admin Scripting 03

41

In Brief

3.Scripting Installations

and Updates• /Q—Runs in quiet mode, skips all prompts

• /Q:U—Runs in user quiet mode, shows some dialog boxes

• /Q:A—Runs in admin quiet mode, shows no dialog boxes

• /R—Reinstalls the application

• /R:A—Always reboots

• /R:I—Reboots if necessary

• /R:N—Does not reboot, even if necessary

• /R:S—Reboots without prompting

• /T:path—Specifies or extracts files to a temporary workingfolder

• /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

Windows and WizardsMany of the tasks of an administrator involve navigating through in-teractive windows and wizards. Whether installing a new program oradding a new piece of hardware, these wizards guide the user througha complicated setup process. This process involves scrolling throughselections, clicking check boxes, selecting tabs, browsing, enteringtext, and more. Although these wizards are helpful, they frequentlydo not support scripting.

In the past, administrators used macro recorders to deal with theseunscriptable windows and wizards. The main problem with basic macroutilities is that they are great for performing linear tasks, but they chokewhen dealing with complex routines that require decisions. The solu-tion is to use a send-keys utility, such as AutoIt.

Scripting Windows with AutoItAutoIt (www.autoitscript.com) is a free automation tool that cansend key and mouse commands to Windows objects. AutoIt detectswindow titles and text and sends commands to specific windowsbased on that information. AutoIt reads commands stored in a text-based script file and performs the commands on a line-per-line basis.Although you can use other scripting send-keys methods, such asWindows Script Host (WSH) or KiXtart, AutoIt provides the easiestway to detect windows and send keys.

Page 5: Windows Admin Scripting 03

42

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

sDetecting Windows and Text

Sometimes multiple windows can have the same title. Luckily, AutoItallows you to specify a combination of window title and window textto specify the exact window you want. Running the “AutoIt WindowsInformation” utility allows you to see the title, text, sizes, and mousecoordinates of the currently active window in real time. You can startthis utility from the AutoIt start menu folder.

For example, suppose you wanted to script the Add New HardwareWizard window (see Figure 3.1). Running the utility would show thewindow title and text (see Figure 3.2).

Adlibbing with AutoItOne of the advantages that AutoIt has over using other send-key meth-ods, such as KiXtart or WSH, is the ability to immediately interceptwindows that may occur unexpectedly. AutoIt refers to the ability tohandle unexpected Windows as “adlibbing”. In order to use adlibbing,you must first enable it with the AdlibEnable command. When thescript encounters any unforeseen error, window, and so on andadlibbing is enabled, the script can break out from its current loca-tion, execute the “handle” function you specified in the AdlibEnablecommand, and then return to the current location.

Figure 3.1 The Add New Hardware Wizard window.

Page 6: Windows Admin Scripting 03

43

In Brief

3.Scripting Installations

and Updates

Convert Script Files to EXEsIncluded in the AutoIt installation package is a utility called AUT2.EXEused to convert AutoIt script files into standalone executables. Youcan even password protect these executables from being turned backinto AutoIt scripts. By converting your scripts, you can prevent usersfrom reading your code and modifying your scripts. The conversionutility is menu-based and allows you to set your own executable icon,provided that it is 32 by 32 pixels in 16 colors.

Scripting AutoIt through COMYou can control AutoIt with KiXtart or Windows Script Host (or anylanguage that can interact with COM) through AutoIt’s COM objectcalled AutoItX3. To gain access to AutoItX3, you must first use theCreateObject function and set it to a variable:

Set variable = CreateObject("AutoItX3.Control")

NOTE: For more information and details on usage, see the AutoItX3 control documentationincluded in the program install.

Figure 3.2 Detecting window title and text with /REVEAL.

Page 7: Windows Admin Scripting 03

44

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

sMicrosoft Windows Installer

Before Windows 2000, installing and managing applications was a com-plete mess. Software companies created their own installation inter-faces, each with its own set of rules, command-line options, and uninstallfunctions. This provided headaches for administrators who attemptedto create common scripting solutions for application installations. Tohelp reduce total cost of ownership (TCO) and provide a standardizedset of installation rules, Microsoft created the Windows Installer.

The Windows Installer is a new installation and configuration ser-vice for 32-bit Windows platforms that standardizes the way pro-grams install and uninstall. The Windows Installer is a ZeroAdministration Windows initiative and is required to conform to the“Designed for Microsoft Windows” logo standards. Some of the ad-vanced features of the Windows Installer are self-repair, rollback,and install on demand. The Windows Installer comes packaged withWindows 2000 and above, and is available as a separate downloadfor Windows 9x and Windows NT.

The Windows Installer runs as a two-part installation utility that con-sists of a client engine and a system service. The client engine(MSIEXEC.EXE) runs with user privileges and provides the interfacebetween the system and the installation service. MSIEXEC.EXE readsthe instructions from the installation package (*.MSI) and passes themto the installation service (Windows Installer).

The installation service enables the system to keep track of all pro-gram installations and system changes, providing for cleaneruninstalls. Because the installation service runs as a system service,it can be given various privileges to allow users to install their ownapplications.

Self-RepairWhen a program file becomes corrupted or missing, a programinstalled with the Windows Installer can identify these files andreplace them automatically. This is a handy feature for those of uswith troublesome users who like to attempt their own uninstalls.

RollbackThe Windows Installer rollback feature creates a temporary backupand script of any files changed during the installation process. If afatal error occurs during the installation, the rollback featureimmediately runs the script and returns the system to its originalstate. All rollback files are stored in a temporary file called config.msi,

Page 8: Windows Admin Scripting 03

45

In Brief

3.Scripting Installations

and Updatesand are automatically deleted when the installation successfully com-pletes. Rollbacks can take a significant amount of disk space andcan be disabled by an administrator.

TIP: You can always delete the config.msi file manually if setup fails to remove it.

Microsoft Windows Installer SwitchesThe MSIEXEC.EXE supports various command-line switches, allow-ing you to control the installer from the command shell or batch file.Here are some of the most common command-line switches forMicrosoft 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

The Scripting AdvantageNowadays, most installations support command line switches to per-form automated installs. While you could these type of installationsusing AutoIt, KiXtart, and Windows Script Host, shell scripting isclearly the most direct and easiest method to use when commandline support is provided. For installations that absolutely do not offeran easy or any way to script the installation, AutoIt’s mouse, keyboard,and Window control capabilities provides us with a last resort forthese tough installations.

A Word of CautionThis chapter contains many scripting examples on performing appli-cation installs and uninstalls. An improper installation/uninstallationmay not only leave the application inoperable, but other applicationsand even the operating system could be harmed as well. As with allscripts, you should first test the script in an isolated testing environ-ment to ensure the script produces the desired results before using itin a production environment.

Page 9: Windows Admin Scripting 03

46

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

sImmediate Solutions

Scripting a Silent .NET FrameworkInstallation

Microsoft .NET is a collection of technologies that allow developersto build, deploy, and maintain applications using a standard set ofclasses. The .NET framework is the common language runtime andset of classes required to run any application built in .NET. To auto-mate a silent installation of the .NET framework, proceed as follows:

1. Create a new directory to store all files included in this ex-ample.

2. Download the .NET framework redistributable fromwww.microsoft.com to the new directory.

3. Start the command prompt and enter the following:

"new directory path\dotnetfx.exe" /q:a /c:"install /l /q"

Here, new directory path is the complete path of the new foldercreated in step 1.

Scripting a Silent MDACS InstallationMDAC (Microsoft Data Access Components) is a set of drivers usedto communicate with databases. While Windows 2000 and laterversions come with a version of MDAC preinstalled, updating yourversion will provide improved performance and stability, as well asprovide access to new data sources. To automate a silent installationof MDACS, proceed as follows:

1. Create a new directory to store all files included in this example.

2. Download the MDACS installer from www.microsoft.com tothe new directory.

3. Start the command prompt and enter the following:

Page 10: Windows Admin Scripting 03

47

Immediate Solutions

3.Scripting Installations

and Updatesnew directory path\executable /q /C:"setup /QN1"

Here, new directory path is the complete path of the new foldercreated in step 1, and executable is the name of the MDACS execut-able downloaded in step 2.

Scripting a Silent Windows 2000/XP ServicePack Installation

The Windows 2000/XP service packs allow you to script an installwithout 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:

new directory path\executable –F –N -O -Q

Here, new directory path is the complete path of the new foldercreated in step 1, and executable is the name of the service packexecutable downloaded in step 2.

Scripting an Internet Explorer DownloadThe Internet Explorer setup utility is a 479kb file that downloads onlythe files needed for your operating system. If you need to installInternet Explorer on fifty systems, you’ll have to sit and wait for it todownload fifty times. To automate the download of Microsoft InternetExplorer 6.x, proceed as follows:

1. Create a new directory to store all files included in this example.

2. Download the Internet Explorer setup file (ie6setup.exe) fromwww.microsoft.com and store it in the new directory.

3. Start the command prompt and enter the following:

new directory path\ ie6setup.exe /c:"ie6wzd.exe /d /s:""#E"

Page 11: Windows Admin Scripting 03

48

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

sHere, new directory path is the complete path of the new foldercreated in step 1.

Scripting a Silent Internet Explorer InstallMicrosoft Internet Explorer is the most widely used Web browser forWindows and comes included with every Windows operating system.To automate the installation of Microsoft Internet Explorer 6.x, pro-ceed as follows:

1. Create a new directory to store all files included in this example.

2. Download the Internet Explorer setup file (ie6setup.exe) fromwww.microsoft.com and store it in the new directory.

3. Start the command prompt and enter the following:

new directory path\ie6setup.exe /Q:A /R:N

Here, new directory path is the complete path of the new foldercreated in step 1.

Related solution: Found on page:Using Microsoft Internet Explorer as a Display Tool 100

Scripting a Silent WinZip InstallationWinZip is the most popular Windows compression utility for the ZIPformat. To automate the installation of WinZip 8, 9, or 10 proceed asfollows:

1. Create a new directory to store all files included in this ex-ample.

2. Download the WinZip installation executable, fromwww.winzip.com, to the new directory.

3. Download and install AutoIt, from www.autoitscript.com, tothe new directory.

4. Double click on the scriptfile.

Page 12: Windows Admin Scripting 03

49

Immediate Solutions

3.Scripting Installations

and UpdatesHere, scriptfile is a text file that contains the following:

Run("WinZipInstallationExecutable.exe")

WinWaitActive("WinZip® ", "http://www.winzip.com")Send("{ENTER}")

WinWaitActive("WinZip® ", "&Setup")Send("!s")

WinWaitActive("WinZip Setup", "Setup will install WinZip intothe following folder")Send("{ENTER}")

WinWaitActive("WinZip Setup", "WinZip features include")Send("!n")

WinWaitActive("License Agreement")Send("!y")

WinWaitActive("WinZip Setup", "For helpful information oninstalling")Send("!n")

WinWaitActive("WinZip Setup", "You can start with the")Send("!c!n")

WinWaitActive("WinZip Setup", "&Express setup (recommended)")Send("!e!n")

WinWaitActive("WinZip Setup", "Associations allow WinZip to")Send("!n")

WinWaitActive("WinZip Setup", "Thank you for installing thisevaluation version")Send("{ENTER}")

WinWaitActive("WinZip (")WinClose("WinZip (")

Scripting a Silent RealVNC InstallationRealVNC is an extremely powerful and free utility to see and controla remote computer (similar to PCAnywhere or Terminal Services).

Page 13: Windows Admin Scripting 03

50

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

sTo automate a silent installation of RealVNC, proceed as follows:

1. Create a new directory to store all files included in this ex-ample.

2. Download the RealVNC installation executable, fromwww.realvnc.com, to the new directory.

3. Start the command prompt and enter the following:

new directory path\vnc-4_1_1-x86_win32.exe /VERYSILENT / COMPONENTS="vncviewer, winvnc" /TASKS="quicklaunchicon, desktopicon, installservice, launchservice"

Here, new directory path is the complete path of the new foldercreated in step 1.

Related solution: Found on page:Connecting to a Remote System through VNC x

Scripting a Silent Windows Media PlayerInstallation

To automate a silent installation of Windows Media Player 10, pro-ceed as follows:

1. Create a new directory to store all files included in this ex-ample.

2. Download the Media Player 10 installation executable, fromwww.microsoft.com, to the new directory.

3. Start the command prompt and enter the following:

new directory path\MP10Setup.exe /q:A /c:"setup_wm.exe /Q /R:N /P:#e"

Here, new directory path is the complete path of the new foldercreated in step 1.

Scripting a Silent DirectX InstallationTo automate a silent installation of DirectX 9b or 9c, proceed as follows:

Page 14: Windows Admin Scripting 03

51

Immediate Solutions

3.Scripting Installations

and Updates1. Create a new directory to store all files included in this ex-

ample.

2. Download the DirectX 9b or 9c installation executable, fromwww.microsoft.com, to the new directory.

3. Start the command prompt and enter the following:

new directory path\DXWebSetup.exe /c:"DXwSetup.exe / windowsupdate" /q /r:n

Here, new directory path is the complete path of the new foldercreated in step 1.

Working with the Windows InstallerThe Windows Installer replaces the old ACME installer, adding morefeatures and functionality. This new installer provides a standardmethod for application installations and an easy way for administra-tors to script installations.

Scripting a Silent Acrobat Reader InstallAcrobat Reader is the most widely used free PDF reader. To auto-mate the installation of Acrobat Reader 7.0, proceed as follows:

1. Create a new directory to store all files included in this ex-ample.

2. Download the Acrobat Reader setup file (AdbeRdr70_enu_full.exe) from www.adobe.com and store it in the new directory.

3. Start the command prompt and enter the following:

new directory path\AdbeRdr70_enu_full.exe /s /v/qn

Here, new directory path is the complete path of the new foldercreated in step 1.

Scripting a QuickTime InstallQuickTime 7 is the latest version Apple’s popular multimedia player.To automate a silent installation of QuickTime 7, proceed as follows:

Page 15: Windows Admin Scripting 03

52

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

s1. Create a new directory to store all files included in this

example.

2. Download the QuickTime setup file from www.apple.com andstore it in the new directory.

3. Start the command prompt and enter the following:

new file path\QuickTimeInstaller.exe /s /v /qn

Here, new directory path is the complete path of the new foldercreated in step 1.

Scripting a Silent pcANYWHERE InstallationPcANYWHERE 11.5 is the latest version of remote control fromSymantec (www.symantec.com). To automate a silent installationof pcANYWHERE 11.5, start the command prompt and enter the fol-lowing:

MSIEXEC /I filepath\ Symantec pcAnywhere.msi /QN

Here, file path is the complete path of the pcANYWHERE 11.5 in-stallation files.

Scripting a Silent Windows 2000 Resource KitInstallationThe Windows 2000 resource kit provides many tools and utilities thatallow you to perform powerful administrative and system tasks. Toautomate a silent installation of a Windows 2000 resource kit, startthe command prompt and enter the following:

MSIEXEC /I DRIVE:\W2000RKPRO.MSI /QN

NOTE: Using the /QB switch may cause the installer to prompt that it is uninstalling the resourcekit when in fact it is installing it.

Here, DRIVE is the CD-ROM drive letter containing the Windows2000 resource kit CD.

TIP: You can script a silent Microsoft TechNet installation using the same install syntax andreplacing the name of the msi file.

Page 16: Windows Admin Scripting 03

53

Immediate Solutions

3.Scripting Installations

and UpdatesScripting the Windows Installer InstallationAlthough the Windows Installer redistributable files usually comepackaged with a program that uses the Windows Installer, they canbe downloaded and installed individually. To automate the installa-tion of the Windows Installer, proceed as follows:

1. Create a new directory to store all files included in this ex-ample.

2. Download the Windows Installer redistributable fromwww.microsoft.com/msdownload.platformsdk/instmsi.htm.

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 foldercreated in step 1, and wiexe is the name of the Windows Installerredistributable executable.

Scripting Microsoft Office 2000/XPMicrosoft Office 2000 was one of the first applications released byMicrosoft to utilize the new Windows Installer. Although the followingexamples are focused toward Microsoft Office 2000 and Office XP,they can be applied to any application that utilizes the new WindowsInstaller.

Removing Older VersionsThe Microsoft Office Removal Wizard can be used to remove olderversions of Microsoft Office before installing Microsoft Office 2000/XP. To automate the removal of older versions of Microsoft Office,start the command prompt and enter the following:

SETUP /S /Q /R /L log file

Here, log file records all activity of the removal process.

NOTE: The Microsoft Office Removal Wizard is included in the Microsoft Office 2000/XPResource Kit.

Scripting a Silent InstallationTo automate the installation of Microsoft Office 2000/XP, start thecommand prompt and enter the following:

file path\SETUP /QN /L*V

Page 17: Windows Admin Scripting 03

54

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

sinstall log COMPANYNAME="company"

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 isthe name of the company registered for Office.

TIP: For more information about Office 2000/XP command-line switches, see the MicrosoftTechNet Article Q202946 (Office 2000) and Q283686 (Office XP).

Scripting an UninstallTo automate the uninstallation of Microsoft Office 2000/XP, start thecommand prompt and enter the following:

file path\SETUP /QN /X msifile

Here, file path is the complete path of the Office installation filesoriginally used to install Office, and msifile is the name of the msipackage to uninstall.

Scripting a RepairTo automate the repair of a Microsoft Office 2000/XP installation, startthe command prompt and enter the following:

file path\SETUP /FOCUMS msifile

Here, file path is the complete path of the Office installation filesoriginally used to install Office, and msifile is the name of the msipackage to repair.

Scripting a ReinstallationTo automate the reinstallation of Microsoft Office 2000/XP, start thecommand prompt and enter the following:

file path\SETUP /FECUMS msifile

Here, file path is the complete path of the Office installation filesoriginally used to install Office, and msifile is the name of the msipackage to reinstall.

AdvertisingInstead of installing an application, you can simply set up the Startmenu shortcuts that, when activated, will install the application onfirst use. This setup method is called advertising. To advertise

Page 18: Windows Admin Scripting 03

55

Immediate Solutions

3.Scripting Installations

and UpdatesMicrosoft Office 2000/XP, start the command prompt and enter thefollowing:

file path\SETUP /QN /JU msifile

Here, file path is the complete path of the Office installation filesoriginally used to install Office, and msifile is the name of the msipackage to advertise.

Disabling Windows Installer RollbacksTo disable the Windows Installer Rollback feature during an installa-tion, start the command prompt and enter the following:

file path\SETUP DISABLEROLLBACK=1

Here, file path is the complete path of the installation files used inthe original installation.

Installing the Windows Installer Clean Up UtilityMicrosoft has created a utility that allows you to delete Windows In-staller registry entries from a system. This is useful when you havecorrupted installations that are preventing you from successfully in-stalling a program. Although the utility’s installer states that it sup-ports the standard Microsoft installation switches, they do not work.To automate the installation of the Windows Installer Clean Up Util-ity, proceed as follows:

1. Create a new directory to store all files included in this ex-ample.

2. Download the Windows Installer Clean Up Utility fromMicrosoft.

For Windows 9x:

download.microsoft.com/download/office2000pro/util22/1/W9X/EN-US/msicu.exe

NOTE: The code above is one continuous statement.

For Windows 2000:

download.microsoft.com/download/office2000pro/util20/1/NT4/EN-US/msicuu.exe

NOTE: The code above is one continuous statement.

Page 19: Windows Admin Scripting 03

56

Chapter 3 Scripting Installations and Updates

3.Sc

riptin

g In

stal

latio

nsan

d Up

date

s3. Download and install AutoIt, from www.autoitscript.com, to

the new directory.

4. Double click on the scriptfile.

Here, scriptfile is a text file that contains the following:

AdlibEnable("AdlibHandler")

RUN("executable")

WinWaitActive("Windows Installer", "It is strongly")Send("!N")

WinWaitActive("Windows Installer", "License")Send("!A!N")

WinWaitActive("Windows Installer", "Start")Send("!N")

WinWaitActive("Windows Installer", "Windows Installer Clean Up hasbeen successfully installed")Send("!F")

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

; Used for uninstallation If WinActive("Windows Installer", "This will remove") Then WinActivate("Windows Installer", "This will remove") Send("!N") EndIf If WinActive("Windows Installer", "Windows Installer Clean Up has been successfully uninstalled") Then WinActivate("Windows Installer", "Windows Installer Clean Up has been successfully uninstalled") Send("!F") EXIT EndIf

Page 20: Windows Admin Scripting 03

57

Immediate Solutions

3.Scripting Installations

and Updates ; Used if wrong version installation is attempted If WinActive("Installer Information") Then WinActivate("Installer Information") Send("!O") EndIf

If WinActive("Fatal Error") Then WinActivate("Fatal Error") Send("{ENTER}") Exit EndIfEndFunc

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 MicrosoftTechNet article Q238413 (Office 2000) and Q290301 (Office XP).

Page 21: Windows Admin Scripting 03