Update INI File Section


UpdateInis

[Update-ini-section-name]
ini-file, ini-section, (old-ini-entry), (new-ini-entry), (flags)

Replaces, deletes, or adds complete entries in the given INI file. The section name, update-ini-section-name, must appear in the UpdateInis item in an Install section of the INF file.

ini-file
Name of the INI file containing the entry to change. For more information about specifying the INI filename, see the comments below.

ini-section
Name of the section containing the entry to change.

old-ini-entry
Optional. Usually in the form Key=Value.

new-ini-entry
Optional. Usually in the form Key=Value. Either the key or value may specify replaceable strings. For example, either the key or value specified in the new-ini-entry parameter may be %String1%, where the string that replaces %String1% is defined in the Strings section of the INF file.

flags
Optional action flags. Can be one of these values:

ValueMeaning
0 (Default) If old-ini-entry key is present in an INI file entry, that entry is replaced with new-ini-entry. Note that only the keys of the old-ini-entry parameter and the INF file entry must match, the value of each entry is ignored.

To add new-ini-entry to the INI file unconditionally, set old-ini-entry to NULL. To delete old-ini-entry from the INI file unconditionally, set new-ini-entry to NULL.

1If both key and value of old-ini-entry exist in an INI file entry, that entry is replaced with new-ini-entry. Note that the old-ini-entry parameter and the INF file entry must match on both key and value for the replacement to be made (this is in contrast to using an action flag value of 0, where only the keys must match for the replacement to be made).
2If the key in the old-ini-entry parameter does not exist in the INI file, then no operation is performed on the INI file.

If the key in the old-ini-entry parameter exists in an INI file entry and the key in the new-ini-entry parameter exists in an INI file entry, then the INI file entry that matches the key in the new-ini-entry parameter is deleted and the INI file entry that matches the old-ini-entry parameter is operated on in the following way: the key of the INI file entry is replaced with the key in the new-ini-entry parameter.

If the key in the old-ini-entry parameter exists in an INI file entry and the key in the new-ini-entry parameter does not exist in an INI file entry, then an entry is added to the INI file made up of the key in the new-ini-entry parameter and the old value.

Note that the match of the old-ini-entry parameter and an INI file entry is based on key alone, not key and value.

3 Same as flag parameter value of 2 described above, except match of the old-ini-entry parameter and an entry in the INF file is based on matching both key and value, not just the key.


The wild card character (*) can be used in specifying the key and value and they will be interpreted correctly.

The ini-file name can be a string or a strings key. A strings key has the form %strkey% where strkey is defined in the Strings section in the INF file. In either case, the name must be a valid filename.

The name should include the name of the directory containing the file, but the directory name should be given as a logical directory identifier (LDID) rather than an actual name. The installer replaces an LDID with an actual name during installation.

An LDID has the form %ldid% where ldid is one of the predefined identifiers or an identifier defined in the DestinationDirs section. Note that when the constants LDID_BOOT and LDID_BOOTHOST are replaced, the backslash is included in the path. For example LDID_BOOT may be replaced with C:\. However, in your INF file you can either use the backslash character or not. For example, either "%30%boot.ini" and "%30%\boot.ini" can be used to reference BOOT.INI in the root of the boot drive.

The following examples illustrate individual items in an Update INI File section of an INF file:

%11%\sample.ini, Section1,, Value1=2 ; adds new entry
%11%\sample.ini, Section2, Value3=*, ; deletes old entry
%11%\sample.ini, Section4, Value5=1, Value5=4 ; replaces old entry

The following set of items in an Update INI File-type section of an INF file work together to operate on the Boot section of SYSTEM.INI. The conditionality built into the flags parameter of the INF file items is used to add the entry "comm.drv=comm.drv" to the Boot section unless the entries "comm.drv=*vcoscomm.drv" or "comm.drv=*r0dmdcom.drv" exist in the Boot section, in which case the existing entry is preserved and the entry "comm.drv=comm.drv" is not added to the INI file. In other words, after the four INF file entries shown below are executed, there will be one "comm.drv=" entry in the Boot section of the INI file: "comm.drv=*vcoscomm.drv" or "comm.drv=*r0dmdcom.drv" or "comm.drv=comm.drv."

system.ini, boot, "comm.drv=*vcoscomm.drv","~CommDrvTemp~=*",3
system.ini, boot, "comm.drv=*r0dmdcom.drv","~CommDrvTemp~=*",3
system.ini, boot,,"comm.drv=comm.drv"
system.ini, boot, "~CommDrvTemp~=*","comm.drv=*",3