You can extend Setup in three ways:
You can use the Run command to execute an Install section in an .inf file. The syntax of the command line is as follows:
RunDll setupx.dll,InstallHinfSection section reboot-mode inf-name
This command assumes that the disk space required to install any files is available. It does not perform any disk-space checks.
The section argument specifies an Install section in the .inf file. The following example shows the command line that installs the optional Games component and, if Windows Update Setup determines that restarting the computer is necessary, prompts the user about whether to restart the computer immediately after the installation is complete.
RunDll setupx.dll,InstallHinfSection games 4 applets.inf
You can specify five reboot modes from the command line:
Important The only recommended values for reboot-mode are 4 (if the .inf file is a 32-bit .inf file) or 132 (if the .inf file is provided by you). Using any of the other values in the preceding list may cause the computer to restart unnecessarily or cause the computer not to restart when it should.
Set reboot-mode to 0 or 128. Whatever happens, the computer is not automatically restarted. It's up to the end user to determine whether the computer should be restarted. For Setup, this means that the C:\Windows\Wininit.ini file is not zero bytes in size.
Set reboot-mode to 1 or 129. The user does not see a prompt about whether to restart the computer, and the computer always restarts.
Set reboot-mode to 2 or 130. The user always sees a prompt about whether to restart the computer. Windows Update Setup does not try to determine whether restarting the computer is necessary.
Set reboot-mode to 3 or 131. If Windows Update Setup determines that the computer needs to be restarted, there is no user interaction.
Set reboot-mode to 4 or 132. If Windows Update Setup determines that the computer needs to be restarted, it prompts the user with a dialog box.
If inf-name specifies your .inf file instead of a Windows .inf file, add 128 to the values shown above. In the example described previously, the reboot-mode for the Games optional component is set to 4 because Applets.inf is a Windows .inf file. If you are installing an optional component that has its own .inf file, you should set reboot-mode to 132. If you add 128 to reboot-mode, all of the files that you are installing must be in the same folder location as your .inf file on the installation disk.
After Windows is installed on a computer, it may be necessary to add one or more of the Windows optional components (for example, Games). This type of installation, which occurs after Windows Update Setup initially installs Windows, is called maintenance-mode setup. Typically, you start maintenance-mode setup from Windows by clicking the Add/Remove Programs icon in Control Panel. However, if you are a vendor or a supplier of an optional software component, you can install the optional component by using a call to the CreateProcess function in a 32-bit program.
Note You can use the CreateProcess function to install an optional component only in 32-bit programs.
To install an optional component from a 32-bit program, use a combination of the following methods:
Before starting the installation operation, determine whether the optional component is currently installed. You can do this by either checking in the registry or looking for the files. The registry path for information about all the currently installed optional components follows:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\SETUP\OptionalComponents
Values under OptionalComponents point to subkeys, and each subkey contains information about the optional components installed, as well as information needed to install a new optional component. For example, to see whether Games are installed as an optional component, look for the following entry under OptionalComponents:
"Games"="Games"
Then, open the Games subkey under OptionalComponents to find the following information:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\SETUP\OptionalComponents\Games
The following example shows that the Games optional component is not installed on this Windows computer, because the Installed entry is set to 0.
"INF"="applets.inf"
"Section"="games"
"Installed"="0"
You can install an optional component, such as Games, by using the INF and Section values in the Games subkey (shown in the previous example) in a call to the CreateProcess function, which then runs Setupx.dll using Rundll.exe. The call to CreateProcess does exactly what the Add/Remove Programs dialog box in Control Panel does when it installs a component. The command-line string specified in the lpCommandLine parameter for CreateProcess has the following syntax:
RunDll setupx.dll,InstallHinfSection section reboot-mode inf-name
The values for section and inf-name are those found in the registry key described earlier. This example shows the command-line string used by CreateProcess to install the optional Games component and, if Windows Update Setup determines that restarting the computer is necessary, to prompt the user whether to restart immediately after the installation is complete.
RunDll setupx.dll,InstallHinfSection games 4 applets.inf
Note It is recommended that you have your installation program check for available disk space before it installs the component. When your program checks for available disk space, it should determine whether there is sufficient disk space for system swap files.
Your installation program must not have any code that executes after the call to CreateProcess, because once Setupx.dll has control, the additional code may cause the user's computer to restart. If your installation process requires other code to run after the call to CreateProcess, use the RunOnce entry in your .inf file.
Caution The RunOnce entry must not run the optional component that you are installing.
Setup recognizes a special installation section name, [DefaultInstall], in .inf files that install optional components. If you use that section in your .inf file, the user can right-click a file icon for the .inf file in the user interface of 32-bit Windows versions to run the [DefaultInstall] section. (After the user right-clicks the .inf file icon, a pop-up menu appears with installation options the user must select from to actually run the [DefaultInstall] section.
The [DefaultInstall] section in the .inf file provides a convenient method of installing optional components. It is particularly useful during the development of your installation program because it provides you with a method for installing your optional component before you write the installation program.
The following example shows typical entries in a [DefaultInstall] section:
[DefaultInstall]
CopyFiles=QCD.copy.prog, QCD.copy.hlp, QCD.copy.win, QCD.copy.sys, QCD.copy.inf
UpdateInis=QCD.Links
AddReg=QCD.reg, QCD.run
Uninstall=FlexiCD_remove