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 runs. For example, you enter the following line to the [GuiRunOnce] section to start the application installation program automatically:
"%systemdrive%\ <appfolder>\<appinstall> -quiet"
If you plan to use [GuiRunOnce] to initiate an installation, there are some additional factors to take into consideration:
If the application forces a reboot, determine whether there is a way to suppress the reboot. 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 will not be run. If there is no way within the application to suppress a reboot, you can try repackaging the application into a Windows Installer package There are third-party products that provide this functionality.
Windows 2000 ships with WinINSTALL LE (Limited Edition), a repackaging tool for Windows Installer. WinINSTALL LE allows you 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 Server CD.
For more information about Windows Installer packaging, see "Automating Client Installation and Upgrade" in this book.
If you are installing an application to multiple localized language versions of Windows 2000, it is recommended that you test the repackaged application on the localized versions to ensure that it copies the files to the correct locations and writes the required registry entries appropriately.
If an application requires a Windows Explorer shell to install, the [GuiRunOnce] section will not work because the shell is not loaded when the Run and RunOnce commands are carried out. Check with the application vendor to determine if they have an update or patch that can address this situation for the application setup. If not, you can 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 command is not used This can happen when an application installation is running and starts another process. When the Setup routine 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 will usually fail. For an example of how to control this using a batch file, see "Using a Batch File to Control How Multiple Applications Are Installed" later in this chapter.
Using Application Installation Programs
The preferred method for preinstalling an application is to use the installation routine supplied with the application. You can do this if the application that you are preinstalling is able to run in quiet mode (without user intervention) by using a /q or /s command-line switch. See the application Help file or documentation for a list of command-line parameters supported by the installation mechanism.
Following is an example of a line that you can place in the [GuiRunOnce] section to initiate the unattended installation of an application 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. This is useful in helping to control application installations with a minimal number of reboots.
Make sure that you check with the application vendor for information, instructions, tools, and best practices information before you preinstall any application.
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 command line 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, how to install the application, and then how to remove all references to the batch file after installation is complete.
To install applications using a batch file
Create the batch file containing lines similar to the following example:
Start /wait <path to 1st application>\<Setup> <command line parameters>
Start /wait <path to 2nd application>\<Setup> <command line parameters>
<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.
<command line parameters> are any available quiet-mode parameters appropriate for the application you want to install.
Copy the batch file to the distribution folders or another location that can be accessed during setup.
With <filename>.bat as the name of the batch file, include an entry in the [GuiRunOnce] section of the answer file to run the batch file, similar to the following example. This example assumes that the batch file was copied to the Sysprep folder on the local hard disk, though it can be located anywhere that Setup has access to during an installation.
" < path-n>\<Command-n>.exe"
- <path-1>\<Command-1.exe> ** and <path-n>\<Command-n.exe> ** are fully qualified paths to additional applications or utility installations or configuration tools. This can also be a path to another batch file. These paths must be available during setup.