Export (0) Print
Expand All

Chapter 17 - Working With .INF Files

In addition to using the Microsoft® Internet Explorer Administration Kit (IEAK) 6, batch files, command-line switches, and third-party applications to customize setup, you can create customized setup solutions by using setup information (.inf) files. The .inf files allow you to use the built-in Microsoft® Windows® setup engine to automate setup tasks such as creating files and folders and providing uninstall functionality for the software components that you install as part of your custom browser packages. This chapter describes .inf files and discusses the ways you can use these text files to customize your installations of components.

Related Information in the Resource Kit

  • For more information about testing the deployment process before the final rollout of Microsoft Internet Explorer 6, see "Setting Up and Administering a Pilot Program." 

  • For more information about building custom browser packages, see "Running the Microsoft Internet Explorer Customization Wizard." 

  • For more information about rolling out Internet Explorer to your users, see "Deploying Microsoft Internet Explorer 6." 

  • For more information about .inf files, see the appendix "Structural Definition of .inf Files." 

Overview: Customizing Installations by Using .inf Files

You can use .inf files to create customized setup instructions, including registry entries and destination directories, for the software components that you want to install as part of your custom browser packages. When users install Internet Explorer, Windows Update Setup for Internet Explorer 6 and Internet Tools follows these instructions to install and register the components and any required files. For each component, you need to ship only the .inf file, which contains your customized setup instructions, and the component's program files.

The .inf files specify the program files required for components to run on 32-bit versions of Windows. By using the setup engine built into Windows, .inf files can take advantage of the setup engine's small size, as well as functions of the Windows operating system such as copying files, adding registry entries, and creating shortcuts. The .inf files can also provide limited platform independence and specify limited software dependencies.

To get started, you can use the guidelines in this chapter to edit one of your existing .inf files or the sample .inf file, which is located in the \IEAK6\Toolkit\Inf folder of your installation directory. These guidelines walk you through the process of customizing the setup instructions for software components. To review a sample .inf file and learn more about .inf file sections, see the appendix "Structural Definition of .inf Files" in this Resource Kit.

After you edit the .inf file for a component, you can use the IExpress Wizard, which is part of the IEAK, to package the .inf file and the component's program files into a self-extracting cabinet (.cab) file. When you run the Internet Explorer Customization Wizard, you can use the Add Custom Components page to add this .cab file to your custom browser packages. For more information about the IExpress Wizard, see "Preparing for the IEAK" in this Resource Kit. For more information about the Add Custom Components screen, see "Running the Microsoft Internet Explorer Customization Wizard" in this Resource Kit.

Manipulating Program Files and Folders by Using .inf Files

You can use .inf files to manipulate the program files and folders for the components that you want to install. You can create folders and links in folders, manage long file names, set attributes for files and folders, and copy files to the Program Files folder.

Creating Folders and Links in Folders

After Setup installs a component, it creates a folder in the Program Files folder or creates links in a folder. Setup looks in the Setup.ini file for a [progman.groups] section and then parses it to create the folders or the links in those folders.

Setup.ini uses the following syntax to create the folders and links:

[progman.groups] 
folder_1=Folder_1_Name 
folder_2=Folder_2_Name 
: 
folder_n=Folder_n_Name
[folder_1] 
link-name, .exe-name, icon-file-name, icon-index, profile

These folders are relative to the Start menu. If you specify NULL as the .exe-name and the name already exists in the group, Setup deletes it. If you specify NULL as the profile, Setup always adds the link to the folder. Also, if a folder or link has a space in its description, you must use double quotation marks.

If you want to install a component that requires a folder or links in the Program Files folder, you must also add to your .inf file an [UpdateInis] section that creates the proper entries for the folders and links in the Setup.ini file. An UpdateInis entry in the [Install] section of the .inf file initiates the [UpdateInis] section. For complete information about the [UpdateInis] section and the UpdateInis entry in the [Install] section of the .inf file, see the appendix "Structural Definition of .inf Files" in this Resource Kit.

Note Microsoft® Windows® 2000 does not support the [UpdateInis] section for creating links. Instead, Windows 2000 uses a new method, ProfileItems, which also supports ToolTip pop-up text. Therefore, you must write a separate .inf file for Windows 2000. For more information, see your Windows 2000 documentation.

The following example shows a Games entry that appears in the Optional Components dialog box during setup. If the user selects this option, Setup creates in the Program Files folder a Games folder with links to Solitaire, Minesweeper, Hearts, and FreeCell.

[Optional Components]
games
[games]
OptionDesc= %GAMES_DESC%
CopyFiles= wingames.files
UpdateInis= wingames.links
[wingames.files]
cards.dll
freecell.exe
freecell.hlp
mshearts.exe
mshearts.hlp
sol.exe
sol.hlp
winmine.exe
winmine.hlp
[wingames.links]
setup.ini, progman.groups,, "gamesfolder=%GAMES_DESC%" ;creates folder
setup.ini, gamesfolder,, """Solitaire Game"",SOL.EXE,,," ;creates link
setup.ini, gamesfolder,, "Minesweeper,WINMINE.EXE,,," ;creates link
setup.ini, gamesfolder,, """Hearts Card Game"",MSHEARTS.EXE,,,";
creates link
setup.ini, gamesfolder,, "FreeCell,FREECELL.EXE,,," ;creates link

Managing Long File Names

To support backwards compatibility, the setup engine in Windows 32-bit versions of the browser is a 16-bit dynamic-link library (.dll) file. Because of this 16-bit limitation, the setup engine can copy only files that have short (8.3) file names.

To manage files with long names, before the setup engine closes, it runs a Windows 32-bit program that renames these short file names to their long file names. During an uninstall, the same program can delete the long file names. This program gets its instructions from predefined paths in the registry. You can specify the registry settings for these rename and delete operations by including this information in the [AddReg] section of your .inf file.

The following registry key specifies the rename operations:

HKEY_LOCAL_MACHINE \Software \Microsoft \Windows \CurrentVersion \RenameFiles

The following registry key specifies the delete operations:

HKEY_LOCAL_MACHINE \Software \Microsoft \Windows \CurrentVersion \DeleteFiles

You must add each group of rename and delete operations as separate entries under each registry key. Each group of operations can rename or delete only files in a single folder. For each rename or delete operation, you must include a minimum of two entries in each subkey: the folder path for the files that you want to rename or delete, and the actual rename or delete operation. The first element in each group of operations is the folder entry. After the program processes these rename and delete operations, it removes the entries from the registry.

Rename Operations

Each rename operation in the folder entry uses the following format:

"old_short_name"="new_long_name,[attrib_flag]"

You can use the optional attrib_flag to set file attributes during the rename operation. This flag can accept the following values:

READONLY

1

HIDDEN

2

SYSTEM

3


To set multiple attributes for a file or folder, you must add the values. For example, to set the READONLY and HIDDEN attributes, you would set the attrib_flag to a value of 3.

The following example shows an [AddReg] entry that sets the SYSTEM and HIDDEN attributes for the \Windows\System32\Sample folder:

HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sys,,,%11%
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sys,SAMPLE,,
"SAMPLE,5"

As shown in the previous example, you must use all capital letters to maintain a short file name.

The following example shows an [AddReg] entry that renames Oldname.txt to New_Long_Name.txt in the C:\Samples folder and then renames Myreadme.txt to My_App_Readme.txt in the Windows folder.

[MyAppShort2Long]
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Samples,,,
C:\Samples
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\
Samples,Oldname.txt,,"New_Long_Name.txt"
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Win,,,%25%
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Win,Myreadme.txt,
,"My_App_Readme.txt"

Note Before renaming any files, the Windows 32-bit program deletes the destination file. Therefore, if you repeat a rename operation, it could result in a loss of the file. For example, if Windows_Screen_Picture.bmp already exists from an earlier rename operation and you attempt to rename Picture.bmp to Windows_Screen_Picture.bmp, the originally existing file might get deleted before the rename operation occurs. If the existing destination file name is a folder, though, this rule does not apply.

Delete Operations

Each delete operation in the folder entry uses the following format:

"arbitrary_key_name"="long_name_to_delete"

The following example shows an [AddReg] entry that deletes New_Long_Name.txt from the C:\Samples folder and then deletes My_App_Readme.txt from the Windows folder.

[MyAppDelLong]
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Samples,,,
C:\Samples
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\
Samples,oldname.txt,,"New_Long_Name.txt"
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Win,,,%25%
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\
Win,myreadme.txt,,"My_App_Readme.txt"

Setting Attributes for Files and Folders

To set the attributes for a file or folder, you must use the same convention that you use to create long file names with the optional attrib_flag parameter. For more information, see "Managing Long File Names" earlier in this chapter.

Copying Files to the Program Files Folder

Because copying Windows files is a 16-bit operation, you must use only short file names. Therefore, to access the Program Files folder, you must use the 8.3 equivalent, "24,PROGRA~1", in the [DestinationDirs] section of your .inf file. Similarly, you must use the short file name equivalent to access any folders with long file names in the Program Files folder.

The following example copies three files to the \Program Files\Accessories folder and creates links to one of the files:

[WordPadInstall]
CopyFiles = WordPadCopyFiles
UpdateInis = WordPadInis
[DestinationDirs]
WordPadCopyFiles = 24,%PROGRAMF%\%ACCESSOR%
[WordPadCopyFiles]
mswd6_32.wpc
wordpad.exe
write32.wpc
[WordPadInis]
setup.ini, progman.groups,, "group4=%APPS_DESC%"
;creates Accessories folder (if not already there)
setup.ini, group4,, """%WORDPAD_LINK%"", 
""%24%\%PROGRAMF%\%ACCESSOR%\WORDPAD.EXE"""
;creates link in Accessories folder
[Strings]
APPS_DESC = "Accessories"
WORDPAD_LINK = "WordPad"
; Folder names - note that 
the short versions must match the truncated
; 8-character names for the long versions, or there will be problems.
PROGRAMF = "Progra~1" ; first 6 chars of Program_Files, + "~1"
ACCESSOR = "Access~1" ; first 6 chars of Accessories, + "~1"

Extending Setup

You can use .inf files to extend Setup in the following ways:

  • Execute Windows .inf files from the command line by using the Run command. 

  • Install optional Windows components by using 32-bit program code rather than by using the Add/Remove Programs dialog box in Control Panel. 

  • Create file icons on the Windows desktop that the user can right-click to run .inf files. 

Running .inf Files from the Command Line

If you want to start the setup program for a component from the command line, you can use the Run command (Rundll.exe or Rundll32.exe) to carry out the [Install] section in the component's .inf file.

The following command-line syntax executes the [Install] section:

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

The section parameter specifies the [Install] section in the .inf file. The reboot-mode parameter identifies how the computer should restart after the installation is complete.

The following table describes the five reboot modes that you can specify from the command line.

Reboot Mode

Value

Description

define HOW_NEVER_REBOOT 0

0 or 128

The computer does not restart automatically, and the user must decide whether to restart the computer without prompting from Setup.

define HOW_ALWAYS_SILENT_REBOOT 1

1 or 129

Setup always restarts the computer automatically without prompting the user.

define HOW_ALWAYS_PROMPT_REBOOT 2

2 or 130

Setup always prompts the user about whether to restart the computer without attempting to determine whether the computer requires restarting.

define HOW_SILENT_REBOOT 3

3 or 131

If necessary, Setup restarts the computer without any user interaction.

define HOW_PROMPT_REBOOT 4

4 or 132

If the computer requires restarting, Setup prompts the user with a dialog box.


Important If inf-name specifies an .inf file that you provide rather than an .inf file that was shipped with a Windows 32-bit product, use the values 128 through 132. Also, if you specify an .inf file that you provide, all of the program files must exist in the same folder location on the installation disk as that .inf file.

The only recommended values for reboot-mode are 4 (for a Windows 32-bit .inf file) and 132 (for an .inf file that you provide). Using any of the other reboot-mode values might cause the computer to restart unnecessarily or cause the computer not to restart when it should.

This Run command assumes that the computer has the disk space required to install the files. It is recommended that you make your installation program check for available disk space before installing the component.

Your installation program must not include any code that executes after the call to Rundll or Rundll32, because after Setupx.dll takes control, the additional code might cause the user's computer to restart. If your installation process requires other code to run after the call to Rundll or Rundll32, include a RunOnce entry in your .inf file. You should not use a RunOnce entry to run the installation program. For more information about RunOnce, see "Using RunOnce Technology" later in this chapter.

The following example shows the command line that installs the Games optional component. If Setup needs to restart the computer after the installation, it prompts the user with a dialog box.

RunDll setupx.dll,InstallHinfSection games 4 applets.inf

In this example, reboot-mode for the Games optional component uses a value of 4 because Applets.inf is a Windows 32-bit .inf file. If you want to install a component with your own .inf file, set reboot-mode to 132.

Installing Optional Components by Using 32-bit Programs

After you install Windows on a computer, you might want 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, you start maintenance-mode setup from Windows by clicking Add/Remove Programs in Control Panel. However, as a vendor or a supplier of an optional software component, you can also install the optional component by using a call to the CreateProcess function in a Windows 32-bit program.

To install an optional component from a Windows 32-bit program, you can use a combination of the following methods:

  • Registry keys 

  • The CreateProcess function 

Checking the Registry

Before starting the installation operation, you must determine whether the optional component is already installed on the computer by either checking the registry or looking for the component's program files. Windows uses the following registry path to maintain information about all the currently installed optional components:

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 on the computer as well as information needed to install a new optional component. For example, to check whether the Games optional component is installed, look for the following entry under OptionalComponents:

"Games"="Games"

Then open the Games subkey under OptionalComponents. The following example shows that the Games optional component is not installed on this computer, because the Installed entry is set to 0:

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

Calling the CreateProcess Function

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. This function then uses Rundll.exe to run Setupx.dll, which is the same event that occurs when the Add/Remove Programs dialog box in Control Panel installs a component. The command-line string specified in the lpCommandLine parameter for CreateProcess uses the following syntax:

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

The section parameter specifies the [Install] section in your .inf file. The reboot-mode parameter identifies how the computer should restart after the installation is complete. For a description of reboot-mode values, see "Extending Setup" earlier in this chapter.

This command assumes that the computer has the disk space required to install the files. It is recommended that your installation program check for available disk space before installing the component. The program should determine whether sufficient disk space exists for system swap files.

Your installation program must not include any code that executes after the call to CreateProcess, because after Setupx.dll takes control, the additional code might cause the user's computer to restart. If your installation process requires other code to run after the call to CreateProcess, include a RunOnce entry in your .inf file. You should not use a RunOnce entry to run the installation program. For more information about RunOnce, see "Using RunOnce Technology" later in this chapter.

The following example shows the command-line string used by CreateProcess to install the Games optional component. If Setup needs to restart the computer after the installation, it prompts the user with a dialog box.

RunDll setupx.dll,InstallHinfSection games 4 applets.inf

Using File Icons to Run .inf Files

You can use the [DefaultInstall] special installation section in your .inf file to install optional components. If you include the [DefaultInstall] section in your .inf file, a user running a 32-bit version of Windows can right-click a file icon to run the [DefaultInstall] section of your .inf file. After the user right-clicks the file icon, a shortcut menu displays a set of installation options. The user can select from these options to run the [DefaultInstall] section.

The [DefaultInstall] section in the .inf file provides a convenient method for installing optional components. It is particularly useful when you develop your installation program, because it provides a method for installing the optional components before you write the installation program. For complete information about the [DefaultInstall] section, see the appendix "Structural Definition of .inf Files" in this Resource Kit.

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

Providing Uninstall Functionality in .inf Files

You can provide uninstall functionality to remove program files, registry entries, and shortcuts by adding the [DelFiles] and [DelReg] sections to your .inf file. DelFiles and DelReg entries in the [OtherInstall] section of the .inf file initiate the [DelFiles] and [DelReg] sections. For complete information about the [DelFiles] and [DelReg] sections and the DelFiles and DelReg entries in the [OtherInstall] section of the .inf file, see the appendix "Structural Definition of .inf Files" in this Resource Kit.

You can also include in the [AddReg] section of your .inf file registry information that adds your component to the list of programs that the user can uninstall from the Add/Remove Programs dialog box in Control Panel.

To add your component to the Add/Remove Programs dialog box, include the following [AddReg] entries in your .inf file:

HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\app-
name,"DisplayName",,"display description"
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\app-
name,"UninstallString",,"command-line"

The "display description" appears in the list box in the Add/Remove Programs dialog box. The "command-line" executes when the user selects the component from the list box in the Add/Remove Programs dialog box. To execute a section in an .inf file, you can use the InstallHinfSection entry-point function in Setupx.dll.

Note When Setup installs the component, your installation code must copy the .inf file to the \Windows\Inf folder. Setup searches this default folder location when your installation code calls the InstallHinfSection entry-point function.

Your code for uninstalling the component should remove the subkey that you created under the Uninstall registry key so that your component will no longer appear in the Add/Remove Programs list box after the user uninstalls it.

The following example shows [AddReg] entries that add "My Test Application" to the list box in the Add/Remove Programs dialog box and execute the [Remove_TestApp] installation section in Test.inf:

HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Test,"DisplayName",,"My Test 
Application"
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Test,"UninstallString",,"Run
Dll setupx.dll,InstallHinfSection Remove_TestApp 4 test.inf"

Using RunOnce Technology

You can run any program after an .inf file has run by adding entries to the RunOnce registry key. This registry key allows you to start programs one time in Windows and specify whether the programs install silently (without prompts to your users) or as part of a list of programs or actions that users see.

You can add entries to the RunOnce registry key by including them in the [AddReg] section of your .inf file. If the .inf file specifies that the computer must restart, the RunOnce entries execute after the computer restarts. Setup then deletes the reference to the program so that it does not run again.

The following registry key specifies that programs run silently:

HKEY_LOCAL_MACHINE \Software \Microsoft \Windows \CurrentVersion \RunOnce

The following registry key specifies that programs run as part of a list of programs or actions that the user sees:

HKEY_LOCAL_MACHINE \Software \Microsoft \Windows \CurrentVersion \RunOnce \Setup

The RunOnce entries use the following format:

"description­string"="command­line"

The "description-string" provides the name of the program, which appears in the list of programs or actions that the user sees. The "command-line" starts the program.

The following example shows an [AddReg] entry that starts Myapp.exe (located in the Windows folder) and installs the program silently. A second [AddReg] entry then starts Test.exe (located in the System32 folder) and displays the following message to the user: "Windows Setup is now setting up the following items."

HKLM,Software\Microsoft\Windows\CurrentVersion\RunOnce,"SilentApp",,"%25%\
myapp.exe"
HKLM,Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup,"Test 
Utility",,"%11%\test.exe"

Limitations of .inf Files

The following limitations apply to .inf files:

  • You cannot delete a directory. 

  • The RenFiles entry only renames a file in its existing location. You cannot use this entry to move a file to a different location. 

  • The CopyFiles entry only copies files from the source disk to the destination directory. You cannot use this entry to copy a file to another location on your hard disk. 


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