|Learning About Computers and the Internet|
One way to edit the Windows Registry is with a special file type with the extension INF. Its construction and use is described.
Background and Introduction to INF Files
INF (Information) files have been around for a long time. They are text files with the file extension .inf, which can be used to carry out a variety of computer tasks. Most PC users will have encountered them as a way to install drivers. They also provide a method for editing the Registry and I sometimes used them for this purpose back in the days of Windows 95. However, in later systems I more or less forgot about INF files in favor of REG files or VBScripts.
INF files fell out of favor for Registry editing partly because their structure can seem a little arcane and is not explained in many places. Even many computer professionals are not sure how to write an INF file or even interpret them. The main reference is in the Windows Driver Development Kit, where the discussion of INF files is none too clear. Another Microsoft reference on INF file architecture is here.
Nonetheless, INF files have advantages and, recently, I have returned to them as a way to edit the Registry. I have been partly motivated by the Windows Registry expert, Jerry Honeycutt, whose book, Windows XP Registry Guide, argues for using INF files and has a useful and clear explanation of their construction. Also, I think that INF files have advantages for use by average home PC users. I summarize some of these next.
Advantages of INF files
Structure and Contents of INF Files for Registry Editing
INF files can have many sections that carry out a variety of functions but I will limit the discussion here to editing the Registry. I will consider files that either add, change, or delete something in the Registry. (I will skip the case where bitwise arithmetic might be involved since bitwise arithmetic can get tricky and will be left to some other time.). The sections of INF files are headed by names that must be enclosed in brackets. The simplest files have three sections. The first section tells the Windows operating system that the file is an INF file and is headed [Version]. The second section defines an action that is to be done if the "Install" entry in the right-click menu is used. The action (also called a directive) will be from a predefined set that the system recognizes as an INF function. In our discussion, the directives are AddReg for adding or replacing Registry entries and DelReg for deleting Registry entries. This second section is headed [DefaultInstall]. This section will also point to a third section that has the actual instructions for the action defined by the directive in the second section. The structure will become clearer with a few simple examples that I will show below. I will include comments within the sample files to help with the explanation, Note that comments are preceded by a semicolon. I will also color comments blue to distinguish them from actual content.First example of an INF file. Adds or replaces a Registry entry
Second example of an INF file. Deletes a Registry entry
Third example of an INF file. Adds one Registry entry and deletes another
If desired, an INF file can have numerous sections to carry out many Registry edits. A schematic example is shown next.Fourth example of an INF file. A more complicated version that edits several Registry entries
INF File Syntax for Adding or Replacing Registry Entries
The entry in an INF file that is used to add or modify existing Registry
settings is written in parts,
each separated by a comma. The syntax for the code must be followed
exactly. It is given by
The remainder of the name of a key, the subkey, is written as one long string.
In the first example above, the subkey is
The next part in is the value name. In the first INF example above, the value is HideFileExt. The value is followed by a flag that indicates what type of Registry value it is. In the example, the flag 0x00010001 indicates that the value is a DWORD. Table II lists the common flags.
The final piece is the actual data for the value. In the example the data entry is 0x00000000. The hexadecimal format is used because this particular example is a DWORD. Other value types would require the appropriate format. For example, the string type REG_SZ would have data of the form "somestring" where the quotation marks are part of the data.
To help keep the discussion clear, here is the complete example
INF File Syntax for Deleting Registry Entries
The syntax for deletions is similar but is shorter. For our
purposes it is given by
More Examples of INF Files for Editing the Registry
I have written some very simple INF files for carrying out useful Registry edits. Some examples are decribed below and can be downloaded by clicking the links. As usual, I must make the disclaimer that they are provided as is and the user is entirely responsible for any results.
How to install an INF file
The actual command that installs an INF file is
|<< Home page||©2002-2014 Victor Laurie||Home page >>|