Executing .INF files from a command line
You can use the Windows 95
RUNDLL or RUNDLL32 system commands to execute an Install section in an .INF file.
The syntax of the command line is:
RunDll setupx.dll,InstallHinfSection
<section> <reboot-mode> <inf-name>
The <section>
parameter is any Install section in the .INF file.
For example the following command line installs the
Games optional component and, if Windows 95 Setup determines a
reboot is necessary, asks the user if they want the computer to
reboot 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
NOTES:
Installing Optional Components from 32-Bit Application Code
After Windows 95 is installed on a computer, it may
be necessary to add one or more of the Windows 95 optional components.
Games is an example of a Windows 95 optional component, and it
is used as an example here. This type of installation, which occurs
after Windows 95 Setup is used to initially install the Windows
95, is called maintenance-mode setup. Typically, maintenance-mode
setup is initiated from the Windows 95 user interface by selecting
the Add/Remove Programs control panel icon. However, there is
an alternative 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: The CreateProcess
method of installing an optional component described below must
only be used 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 if 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:
[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 on the optional
components installed, as well as information needed to install
a new optional component.. For example, suppose you want to install
Games as a optional component. To see if 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 95 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 the Add/Remove Programs control panel does
when it installs a component. The syntax of the lpCommandLine
parameter in the CreateProcess call is:
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 95 Setup determines a
reboot is necessary, asks the user if they want the computer to
reboot 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: It is recommended
that available disk space be checked before installing the component.
When checking for available disk space, consider that there must
be 5 to 10 Mbytes of disk space for system swap files, etc.
Your installation application must not have any code
to execute after the CreateProcess call is made because
once SETUPX.DLL has control, it may cause a reboot. 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: 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 95 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 95 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 directory
location as your INF file on the installation disk.
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 machine
to be rebooted unnecessarily or cause the machine not to be
rebooted when it should be.
The following list describes each reboot mode:
NeverReboot
Set <reboot-mode> to 0 or 128. Whatever happens,
the PC will not be rebooted. Its up to the client to determine
if the PC should be rebooted. 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 with a "Reboot the machine, Yes/No"
dialog and the PC will always reboot.
AlwaysPromptReboot
Set <reboot-mode> to 2 or 130. The user will
always be asked to respond to a "Reboot the machine, Yes/No"
dialog. Setup does not attempt to determine if a reboot is necessary.
SilentReboot
Set <reboot-mode> to 3 or 131. If Setup determines
that the PC needs to reboot, there is no user interaction.
PromptReboot
Set <reboot-mode> to 4 or 132. If Setup determines
that the PC needs to reboot, it prompts the user with a "Reboot
the machine, Yes/No" dialog. .
Using the INF File Install Section Extensions
If you have dependencies on other INF files, extensions
have been added to the INF file install section format. The following
types of items can be added to the install section:
Include=<list
of inf-files>
Needs=<list
of sections>
If there is more than one entry in the Include or
Needs items, separate the entries with a comma as shown in the
example below.
The Include item enables you to specify INF files
that Setup must also load into memory when it loads your INF file
because these INF files contain sections that must be run in addition
to the install sections in your INF file. The Needs item specifies
the names of the sections you intend to run in the included INF
file(s).
For example, you could add the following lines to
an install section in your INF file:
[InstallMyToys]
.
.
.
Include=mos.inf,
msmail.inf
Needs=MSMAIL,
MAPI, MicrosoftNetwork
Running an INF File by Right-Clicking On 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 on a file icon for the INF file in the Windows
95 user interface 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 which 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.
An example DefaultInstall section is given below
to show that its entries are typical of most INF file install
sections:
[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