banner graphic
Reference

Extensions to Windows Setup

You can extend Windows Setup in three ways:

Executing .inf files from a command line

You can use the Windows Rundll.exe or Rundll32.exe system commands 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>

The <section> parameter is an Install section in the .inf file. For example, the following command line installs the Games optional component and, if Setup determines that restarting the computer is necessary, asks users if they want the computer to restart immediately after the installation is complete. (The meaning of the <reboot-mode> parameter values is described in "Using the reboot mode parameter," below.)

RunDll setupx.dll,InstallHinfSection games 4 applets.inf

Notes

Using the reboot mode parameter

There are five reboot modes:

define HOW_NEVER_REBOOT 0
define HOW_ALWAYS_SILENT_REBOOT 1
define HOW_ALWAYS_PROMPT_REBOOT 2
define HOW_SILENT_REBOOT 3
define HOW_PROMPT_REBOOT 4

If <inf-name> specifies your .inf file instead of a Windows .inf file, add 128 to the values shown above. In the example above that installs the Games optional component, <reboot-mode> is set to 4. This is because Applets.inf is a Windows .inf file. If you were installing an optional component that has its own .inf file, you would set <reboot-mode> to 132. If you add 128 to the <reboot-mode> parameter, then all the files you are installing must be in the same folder location as your .inf file on the installation disk.

Note

The following list describes each reboot mode:

NeverReboot
Set <reboot-mode> to 0 or 128. Whatever happens, the computer will not be restarted. It's up to the client to determine whether the computer should be restarted. For Setup, this means there is a file C:\Windows\Wininit.ini that is not zero bytes in size.

AlwaysSilentReboot
Set <reboot-mode> to 1 or 129. The user will not be prompted to restart the computer, and the computer will always restart.

AlwaysPromptReboot
Set <reboot-mode> to 2 or 130. The user will always be prompted about whether or not they want to restart the computer. Setup does not attempt to determine if restarting the computer is necessary.

SilentReboot
Set <reboot-mode> to 3 or 131. If Setup determines that the computer needs to be restarted, there is no user interaction.

PromptReboot
Set <reboot-mode> to 4 or 132. If Setup determines that the computer needs to be restarted, it prompts the user with a dialog box.

Return to top of file

Installing optional components from 32-bit application code

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 Setup initially installs Windows, is called maintenance-mode setup. Typically, maintenance-mode setup is initiated from Windows by clicking the Add/Remove Programs icon in Control Panel. However, an alternative is available to vendors and suppliers of the optional software component: they can install the optional component using a CreateProcess call in a 32-bit application.

Note

To install an optional component from a 32-bit application, use a combination of the methods described below.

Checking the registry

First, check the registry to see whether the optional component is currently installed (or look for the files). The registry key location of information about all the currently installed optional components is as follows:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SETUP\OptionalComponents]

There will be values under this key that 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, suppose you want to install Games as an optional component. To see whether Games are installed, look for the following subkey value under the OptionalComponents key:

"Games"="Games"

Then open the "Games" key under the optional components key to find the following:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SETUP\OptionalComponents\Games]
"INF"="applets.inf"
"Section"="games"
"Installed"="0"

This shows that the Games optional component is not installed on this Windows computer, because the "Installed" flag is set to 0.

Coding a CreateProcess function call

To install an optional component such as Games, use the "INF" and "Section" values in the above key in a CreateProcess call that runs Setupx.dll via RUNDLL. This does exactly what Add/Remove Programs in Control Panel does when it installs a component. The syntax of the lpCommandLine parameter in the CreateProcess call is as follows:

RunDll setupx.dll,InstallHinfSection <section> <reboot-mode> <inf-name>

The values of the <section> and <inf-name> parameters are those found in the registry key described above. For example, the following CreateProcess call installs the Games optional component and, if Windows Setup determines that restarting the computer is necessary, asks the user whether they want the computer to restart immediately after the installation is complete. (The meaning of the <reboot-mode> parameter values is described in the section "Using the reboot mode parameter," below.)

RunDll setupx.dll,InstallHinfSection games 4 applets.inf

Note

Your installation application must not have any code to execute after the CreateProcess call is made, 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 your code makes the CreateProcess call, use the RunOnce list in your .inf file.

Note

Running an .inf file by right-clicking it

Setup recognizes a particular install section name, DefaultInstall, in .inf files that install Optional Components. If you use a [DefaultInstall] 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 on the .inf file icon, a popup menu will be displayed from which the user must select the Install option in order to actually run the [DefaultInstall] section.

Using an install section named [DefaultInstall] in your .inf file provides a convenient method of installing your Optional Component. This is particularly useful during development of your application. If you are going to write an installation application, you have a method for installing your optional component before you develop the installation application code.

The following is an example DefaultInstall section that contains typical entries:

[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