Customizing and Automating Installations

There are several methods from which you can choose to add applications to your installation:

  • Using Cmdlines.txt to add applications during the GUI mode of Setup.

  • Installing applications when the user logs on for the first time by customizing the [GuiRunOnce] section of the answer file.

  • Using batch files.

  • Using Windows Installer.

  • Using the Sysdiff tool to install applications that don't have an automated installation routine.

Using Cmdlines.txt

The Cmdlines.txt file contains the commands that GUI mode runs when installing optional components, such as applications that must be installed immediately after Windows 2000 Professional is installed. If you plan to use Cmdlines.txt, place it in the $OEM$ subfolder of the distribution folder. If you are using Sysprep, place Cmdlines.txt in the $OEM$\$1\Sysprep subfolder.

Use Cmdlines.txt under following conditions:

  • You are installing from the \$OEM$ subfolder of the distribution folder.

  • The application that you are installing:

    • Does not configure itself for multiple users (for example, Microsoft Office 95).

    • Is designed to be installed by one user and to replicate user-specific information.

The syntax for Cmdlines.txt is as follows:

[Commands]

< command_1 >

< command_2 >

.

.

< command_x >

Keys are defined as follows:

  • **<command_1>, <command_2>, <command_x> **refer to the commands that you want to run (and the order in which you want to run them) when GUI mode calls Cmdlines.txt. Note that all commands must be in quotation marks.

When you use Cmdlines.txt, be aware of the following:

  • When the commands in Cmdlines.txt are carried out during setup, there is no logged-on user and there is no guaranteed network connectivity. Therefore, user-specific information is written to the default user registry, and all users receive that information.

  • Cmdlines.txt requires that you place the files that you must have to run an application or tool in directories that you can access during the setup process, which means that the files must be on the hard disk.

important-icon

Important

Applications that can be set up by using Windows Installer cannot be added using Cmdlines.txt.

To specify a Cmdlines.txt file during the mini-Setup portion of Sysprep

  1. Create a Sysprep.inf file to be used by Sysprep. This is a requirement and cannot by bypassed. The Sysprep.inf file must be named Sysprep.inf and be located in the folder Sysprep from the root of the volume that contains the folder % SystemRoot %.

  2. Place the following entry in the [Unattended] section of the Sysprep.inf file:

InstallFilesPath = drive:\path

where:

< path > is any folder you want to use. Microsoft recommends that < drive > be the volume containing the % SystemRoot % folder.

  1. Create the folder drive :\ path . You can use any folder name you want, but it must match the location that you specified in Sysprep.inf.

  2. In the drive :\ path folder, create a folder named $oem$, and then place the Cmdlines.txt file in this folder. This file is processed at the end of the mini-Setup wizard, before saving any settings.

Using the [GuiRunOnce] Section of the Answer File

The [GuiRunOnce] section of the answer file contains a list of commands that run the first time a user logs on to the computer after Setup has run. For example, you enter the following line to the [GuiRunOnce] section to start the application installation program automatically.

[GuiRunOnce]

%systemdrive%\appfolder\appinstall -quiet

If you plan to use the [GuiRunOnce] section to initiate an installation, there are some additional factors to take into consideration.

If the application forces a restart, determine whether there is a way to suppress the restart.    This is important because any time the system restarts, all previous entries in the [GuiRunOnce] section are lost. If the system restarts before completing entries previously listed in the [GuiRunOnce] section, the remaining items are not run. If there is no way within the application to suppress a restart, you can try to repackage the application into a Windows Installer package. There are third-party products that provide this functionality.

Windows 2000 includes Veritas WinINSTALL Limited Edition (LE), a repackaging tool for Windows Installer. You can use WinINSTALL LE to efficiently repackage pre-Windows Installer applications into packages that can be distributed with Windows Installer. For more information about WinINSTALL LE, see the Valueadd\3rdparty\Mgmt\Winstle folder on the Windows 2000 Professional operating system CD.

For more information about Windows Installer packaging, see Using Windows Installer Service later in this chapter.

important-icon

Important

If you are adding an application to multiple localized language versions of Windows 2000 Professional, it is recommended that you test the repackaged application on the localized versions to ensure that the files are copied to the correct locations and the required registry entries are written appropriately.

If an application requires a Windows Explorer shell to install, the [GuiRunOnce] section does not work because the shell is not loaded when the Run and RunOnce commands are carried out.    Check with the application vendor to determine whether an update or patch is available that can address this situation for the application installation. If not, repackage the application as a Windows Installer package or use another means of distribution.

Applications that use the same type of installation mechanism might not run properly if a /wait switch is not used.    This can happen when an application installation is running and starts another process. When Setup is still running, initiating another process and closing an active one might cause the next routine listed in the RunOnce registry entries to start. Because more than one instance of the installation mechanism is running, the second application usually fails.

Using Application Installation Programs

The preferred method for adding an application is to use the installation routine supplied with the application. You can do this if the application that you are adding can run in quiet mode (that is, without user intervention) by using a /q** or /s switch. For a list of switches supported by the installation mechanism, see the application Help file or documentation.

The following is an example of a line that you can place in the [GuiRunOnce] section to initiate the unattended installation of an application by using its own installation program:

<path to setup>\Setup.exe /q

Setup parameters vary between applications. For example, the l parameter included in some applications is useful when you want to create a log file to monitor the installation. Some applications have commands that can keep them from restarting automatically. These commands are useful in helping to control application installations with a minimal number of restarts.

Make sure that you check with the application vendor for information, instructions, tools, and best practices information before you install any application.

important-icon

Important

You must meet the licensing requirements for any application that you install, regardless of how you install it.

Using a Batch File to Control How Multiple Applications Are Installed

If you want to control how multiple applications are installed, you can create a batch file that contains the individual installation commands and uses the Start command with the /wait switch. This method ensures that your applications install sequentially and that each application is fully installed before the next application begins its installation routine. The batch file is then run from the [GuiRunOnce] section.

The following procedure explains how to create the batch file, install the application, and remove all references to the batch file after the installation is complete.

To install applications using a batch file

  1. Create the batch file containing lines similar to the following example:

Start /wait <path to 1stapplication>\Setup <switches>

Start /wait <path to 2ndapplication>\Setup <switches>

Quit

where:

< path> is the path to the executable file that starts the installation. This path must be available during Setup.

Setup is the name of the executable file that starts the installation.

<switches> are any available quiet-mode switches appropriate for the application that you want to install.

  1. Copy the batch file to the distribution folders or another location to which you have access during setup.

  2. With < file name> .bat as the name of the batch file, include an entry in the [GuiRunOnce] section of the answer file to run the batch file, as is done in the following example. This example assumes that the batch file was copied to the Sysprep folder on the local hard disk drive, though it can be in any location to which Setup has access during an installation.

[GuiRunOnce]

%systemdrive%\sysprep\<file name>.bat= <path-1>\Command-1.exe

<path-n>\Command-n.exe

%systemdrive%\sysprep\sysprep.exe –quiet

where:

< path-1>\Command-1.exe and <path-n>\Command-n.exe are fully qualified paths to additional applications or tool installations or configuration tools. This can also be a path to another batch file. These paths must be available during setup.

Using Windows Installer Service

Windows Installer Service is a Windows 2000 Professional component that standardizes the way applications are installed on multiple computers.

When you install applications without using Windows Installer Service, every application must have its own setup executable file or script. Each application has to ensure that the proper installation rules (for example, rules for creating file versions) are followed. This is because the application setup was not an integral part of the operating system development, so no central reference for installation rules exists.

Windows Installer Service implements all the proper Setup rules in the operating system itself. To follow those rules, applications must be described in a standard format known as a Windows Installer package. The data file containing the format information is known as the Windows Installer package file and has an .msi file name extension. Windows Installer Service uses the Windows Installer package file to install the application.

Windows Installer Terminology

The following terms are used to describe the installation process that uses Windows Installer technology:

Resource. A file, registry entry, shortcut, or other element that an installer typically delivers to a computer.

Component. A collection of files, registry entries, and other resources that are installed or uninstalled as a unit. When a particular component is selected for installation or removal, all of the resources in that component are either installed or removed.

Feature. The granular pieces of an application that a user can choose to install. Features typically represent the functional features of the application itself.

Product. A single product, such as Microsoft Office. Products contain one or more features.

Windows Installer Package File

The package file is a database format that is optimized for installation performance. Generally, this file describes the relationships between features, components, and resources for a specific product.

The Windows Installer package file is typically located in the root folder of the Windows 2000 Professional operating system CD or network image, alongside the product files. The product files can exist as compressed files known as cabinet (CAB) files (which have a .cab file name extension). Each product has its own package file. During installation, Windows Installer Service opens the package file for the product and uses the information inside the Windows Installer package to determine which installation operations must be performed for that product.

Sysdiff Tool

The preferred method for automating application installation is to use their own scripting and installation routines. However, you can install applications that do not support this by using the Sysdiff tool. To perform the various steps to add applications, run Sysdiff in several different modes. In /snap mode, Sysdiff.exe takes a snapshot of a clean Windows 2000 Professional computer, and then the applications are installed. A clean copy of Windows 2000 Professional is an installation of Windows 2000 Professional that has not been modified and has not had additional software installed on it. Use Sysdiff in /diff mode to record all the changes that the application installation made to the computer (INI files, the registry, and so on).

Sysdiff creates a difference file or package that includes all the files and settings that you must install with applications on a clean copy of Windows 2000 Professional. Running Sysdiff in /apply or /inf mode applies the package to the clean Windows 2000 Professional installation.

Sysdiff generates the \$OEM$ folder structure in 8.3 file name format for maximum compatibility with OEM preinstallation environments and methods. It places $$Rename.txt in the appropriate folder.

Sysdiff Parameters

The Sysdiff switches are listed in this section. The sections that follow discuss each switch in greater detail. Sysdiff syntax is as follows:

sysdiff[/snap| /diff| /apply| /dump| /inf] [/log:Log_file] [/m]

[/?]

[/dsp]

[/p]

[/q]

[/c:comment]

Snapshot_file

Sysdiff_file

Dump_file

Oem_root

where:

  • / snap , / diff , / apply , / dump , / inf are the modes available. You must specify one of these switches, because this switch determines the Sysdiff mode and specifies how Sysdiff proceeds.

  • Log_file is the name of an optional log file to which Sysdiff writes information describing its actions (used only in /snap and /diff modes).

  • /m is a switch that remaps file changes during the creation of a Sysdiff package so that they appear as Default User files. (Used only in /apply and /inf modes.)

  • /? is a switch that calls the Help file.

  • /dsp is a switch that instructs Sysdiff to not generate the distribution share point that sysdiff /inf normally generates because the files already exist in the appropriate folders on the destination computer. (Used only in /inf mode.)

  • /p is a switch that instructs Sysdiff to not scan all folders and files on the computer for changes. Instead, Sysdiff only scans files in the UserProfile folder. (Used in /snap and /diff modes.)

  • /q is a switch that instructs Sysdiff to run in unattended (quiet) setup mode.

  • comment is the name you give to the Sysdiff package as it appears in an onscreen message during setup. (Used in /diff mode only.) This comment must contain only the names of the applications being added.

  • Snapshot_file is any valid Microsoft Win32 file name. (Used in /snap and /diff modes only.) A snapshot of the system is recorded in this file.

  • Sysdiff_file is any valid Win32 file name. (Not used in /snap mode.) The specified file is the output of Sysdiff and can be applied to a Windows 2000 Professional installation by using sysdiff/apply or sysdiff /inf modes.

  • Dump_file is a Win32 path to a text file that is created to contain the dump. (Used in /dump mode only.) A dump file is used for diagnostic purposes.

  • Oem_root is the Win32 path of a folder. (Used in /inf mode only.) The \$OEM$ structure is created in this folder, and the INF file is placed in this folder and named Sysdiff_file .inf.

Figure 5.3 shows the sequence of steps for using Sysdiff to add applications. The sections that follow discuss each step in greater detail.

Cc977155.prbc_03(en-us,TechNet.10).gif

Figure 5.3 Sysdiff Overview

Sysdiff is used in as many as six different steps to add applications during installation. The following sections explain these steps.

Step 1: Install Windows 2000 Professional on the Reference Computer

Before you add applications by using Sysdiff, you must install a clean copy of Windows 2000 Professional on your reference computer.

important-icon

Important

Do not make any changes to Windows 2000 Professional on the reference computer before you run Sysdiff.

Step 2: Modify the Sysdiff.inf File

You can exclude items from the Sysdiff snapshot by modifying the Sysdiff.inf file. When Sysdiff runs in /snap or /diff mode, it looks for the Sysdiff.inf file in the same folder that contains Sysdiff.exe. This file contains information that Sysdiff uses to exclude certain files and registry entries from snapshots or difference files. To modify the Sysdiff.inf file, follow the instructions in the file.

Step 3: Make a Snapshot of the Clean System

Sysdiff /snap takes a snapshot of a clean system. A clean system is a reference computer that is running Windows 2000 Professional but has no applications installed.

Run Sysdiff in /snap mode to create the snapshot for later difference files.

The syntax for this command is as follows:

sysdiff/snap[/log:Log_file] Snapshot_file

where:

Log_file is the optional name of a log file to which Sysdiff writes information describing its actions. The log file is not used in /apply or /dump modes.

Snapshot_file is any valid Win32 file name. A snapshot of the system is recorded in this file.

Step 4: Create the Difference Files

After you install applications on the reference computer, run Sysdiff with the /diff switch to determine the differences between the new system state of the computer and the earlier, clean system snapshot. The result is a Sysdiff difference file package that contains a description of the INI file changes, registry changes, and other changes (including the application files themselves, which can make Sysdiff packages quite large). You can then apply these changes to another Windows 2000 Professional installation, duplicating the changes made to the reference computer.

important-icon

Important

If you change any of the system's settings after you create the snapshot, you must recreate the snapshot file before you create the difference file.

The syntax for this command is as follows:

sysdiff/diff [/log:Log_file] Snapshot_file Sysdiff_file

/c: comment

where:

Log_file is the optional name of a log file to which Sysdiff writes information describing its actions. The log file is not used in /apply or /dump modes.

Snapshot_file is a file generated by an earlier invocation of sysdiff /snap on the same Windows 2000 Professional installation. (Sysdiff fails if Snapshot_file is from a different Windows 2000 Professional installation.)

Sysdiff_file is any valid Win32 file name. The specified file is the output of Sysdiff, and you can apply it to a Windows 2000 Professional installation by using Sysdiff /apply or Sysdiff /inf .

comment is the name you give to the Sysdiff package. This name appears in a screen message during setup. (Used in /diff mode only.) This comment can contain only the names of the applications being added.

important-icon

Important

Do not try to quit Sysdiff until a message appears informing you that the difference package has been created. If you quit before this message appears, Sysdiff fails.

Step 5: View Difference File Information (Optional)

You can also run Sysdiff in /dump mode, which is a special mode for diagnostic purposes. The output of this command is a text file containing a readable form of the contents of a Sysdiff package.

The syntax for this command is as follows:

sysdiff/dumpSysdiff_file Dump_file

where:

Sysdiff_file is a Win32 path to a file that is created in /diff mode.

Dump_file is a Win32 path to a text file that is created to contain the dump.

Step 6: Apply Difference Files

After you create at least one snapshot on your reference computer and at least one difference file based on that snapshot, you have a Sysdiff package file that can be applied to multiple destination computers during Setup. Two Sysdiff modes can have difference files applied: Sysdiff  /apply and Sysdiff  /inf .

Sysdiff /apply

You can apply Sysdiff packages during setup if the Sysdiff package is available on the hard disk and the correct switch is specified. When a Sysdiff package is applied, Sysdiff copies each file from the package to its final location on the hard disk.

Setup starts Sysdiff in /apply mode to apply a difference file to a Windows 2000 Professional installation. You must specify /m when running Sysdiff in /apply mode. You can specify one or more Sysdiff switches in the Cmdlines.txt file.

The syntax for this command is as follows:

sysdiff /apply /m Sysdiff_file

where:

/m** remaps file changes to the user profile ( UserProfile ) during the creation of a Sysdiff package so that they appear as Default User files. The /m switch is required when running Sysdiff in either /apply or /inf modes.

Sysdiff_file specifies the file that was generated by carrying out sysdiff/diff .

important-icon

Important

The SystemRoot folder must be located in the same position as it was on the system that generated the difference file. That is, if you generate a Sysdiff package on a Windows 2000 Professional installation in C:\Winnt, that Sysdiff package can be applied on other computers only if they are running Windows 2000 Professional installed in C:\Winnt.

Sysdiff /inf

Running Sysdiff /inf also allows Setup to install applications, but in this mode, the Sysdiff package does not contain the actual application files. Instead, Sysdiff determines the files that the application placed on the reference computer and their locations. Sysdiff then copies these files to the corresponding folders in the distribution folder. By including only information that refers to a location for the application files, the Sysdiff package can be much smaller.

Running Sysdiff /inf creates the following files, folders, and settings:

  • \ $OEM$\Cmdlines.txt

  • \ $OEM$\Package .inf Package represents the Sysdiff package file name.

  • \ $OEM$\C \ProgramsC represents the drive where the newly installed application is stored, and Programs represents the folder.

Rather than creating the distribution folder manually, you can use Sysdiff to generate an Inf and \$OEM$ folder structure from the Sysdiff file. The Inf folder contains registry and INI file settings. The \$OEM$ folder structure is created during an early phase of Setup. The application files have already been copied to the hard disk when the GUI mode of Setup begins. This allows greater flexibility in applying changes.

Running Sysdiff in /inf mode creates an INF file that instructs Setup to make the INI file and registry changes contained in the Sysdiff package and also to generate an \$OEM$ folder structure for file changes contained in the Sysdiff package. The folder structure is created using only file names in 8.3 format. The $$Rename.txt files throughout the tree contain mappings from file names in 8.3 format to long file names where necessary. These $$Rename.txt files are used during later phases of Setup.

The syntax for using /inf mode is as follows:

sysdiff /inf /m Sysdiff_file Oem_root

where:

/m remaps file changes during the creation of a Sysdiff package so that the files appear as Default User files. The /m parameter is required when running Sysdiff in /apply or /inf modes.

Sysdiff_file is the Win32 path to a file that was created by running Sysdiff in /diff mode. The name of this file must be no more than eight characters long.

Oem_root is the Win32 path of a folder. The \$OEM$ structure is created in this folder, and the INF file is copied there and named Sysdiff_file.inf.