Sunday, November 23, 2008

Writing simple INF files for installation of software with IEXPRESS

Hi, all:

I have been working on a small project that requires a simple installer. The installer is expected to:
  1. Copy a few files to a location where they can be accessed later, is not too visible, and where the user running the installation process has write access.
  2. Add a registry key
So here is how the INF looks:

[version]
signature="$CHICAGO$"

[DefaultInstall]
CopyFiles = copy.files
AddReg=Add.Settings

[copy.files]
program.exe

[Add.Settings]
HKCU,Software\Microsoft\Windows\CurrentVersion\run\,program,0x00000000,"%16410%\program.exe"

[DestinationDirs]
copy.files = 16410

[SourceDisksNames]
81=,"",1


Brief explanation follows:
  • [version]: just put it there, needed for the INF to work. No particular meaning.
  • [DefaultInstall]: what will be done when the install takes place. In this case, we tell Windows Installer to copy files as specified on [copy.files] and add registry keys as specified on [Add.Settings].
  • [copy.files]: list of files to be copied. One file per line.
  • [Add.Settings]: nasty syntax. HKCU means Registry key HKEY_CURRENT_USER. Next (after first comma) is the registry subkey. Next is the entry name. Next is the registry type of value. Finally, the value itself. So this would produce a REG_SZ entry called program inside HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\run\ with value "c:\documents and settings\username\application data\program.exe". Note that %16410% is expanded to the "Application Data" directory of the user running setup. More on this below. More on Registry manipulation through inf files here.
  • [DestinationDirs]: this tells Windows Installer to cpy files listed on section [copy.files] to directory with ID equal to 16410. Windows XP has a number of directories which are identified by numeric IDs. These IDs are called DIRIDs (original, uh?). 16410 is the DIRID for "Application Data" directory of the user running the setup. Notice that, when used for adding the registry key above, we had to surround it with % symbol, so that it is expanded to a directory instead us using it as a directory called 16410. Full list of DIRIDs is available here.
  • [SourceDisksNames]: this one tells Windows where are the source files. 81 is just some ID for the dir, pick any number you want. Just make sure that if you have several lines on this section, the IDs are different for each one. Next is a description of the disk (empty in our case). Next comes an optional CAB file which has the files (also empty in our case). Next is 1, which is unused on modern Windows versions. More details on this entry can be found here.
Check out my post on using IEXPRESS with this INF file to create an installer.

No comments: