Export (0) Print
Expand All

Extensions to Windows Setup

You can extend Windows Setup in three ways:

  • Execute Windows .inf files from the command line using Rundll.exe.

  • Install optional Windows software components from 32-bit program code as an alternative to the user installing software from the Add or Remove Programs dialog box in Control Panel.

  • Create an icon on the Windows desktop that the user can click to run an .inf file; this eliminates the need to develop installation program code.


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


Note Note 

  • This command assumes that the disk space required to install any files is available. It does not do any disk space checks.

  • Your installation application must not have any code to execute after the RUNDLL or RUNDLL32 call is made, because once Setupx.dll has control, it may cause the computer to restart. If your installation process requires other code to run after your code makes the RUNDLL or RUNDLL32 call, use the RunOnce list in your .inf file.

  • Do not use the RunOnce list to run the Optional Component that you are installing.


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 Note 

  • The only recommended values for <reboot-mode> are 4, if the .inf file is a Windows 95 .inf file, or 132 if the .inf file is provided by you. Using any of the other values shown above may cause the computer to be restarted unnecessarily or cause the computer not to be restarted when it should be.


The following list describes each reboot mode:

NeverReboot
Set <reboot-mode> to 0 or 128. Whatever happens, the computer is not 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 is not 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.

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 or 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 Note 

  • The CreateProcess method of installing an optional component described below must be used only in 32-bit applications.


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 are 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 or 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 Note 

  • It is recommended that available disk space be checked before installing the component. When checking for available disk space, consider that there must be disk space for system swap files.


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 Note 

  • Do not use the RunOnce list to run the Optional Component that you are installing.


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 pop-up menu is 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



Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft