Resource IndexQuick Links
Infsect is an INF/INI file manipulation utility for the command line. It has a number of advantages over some other INI editors, such as the ability to use the program itself to prompt for input when executed in a batch script.
While derived from a Bash script in the original incarnation of Hierma, it is a total rewrite in the C language, easily making it around 20x faster. Its original goal was to be a part of a new, DOS-based Hierma, but that has not made any progress since this program was first written.
Once again, Infsect is completely rewritten, this time with a modest DOS-first approach. The fundamental problem with the last version was that it was trying to do too much all at once right from the start, all for a larger thing that never took off. After being tested in both MS-DOS and Win32, Infsect 0.2 should be better suited as a standalone utility for certain routines. It promises less functionality than the last version, but hey, at least it works now.
Knowing that not very many people are going to end up using this as I previously imagined, I ditched the GPL for it and released every bit of it into the public domain, so it can be used and modified without any restrictions.
Download Infsect 0.2 (MS-DOS, 13.2 KB)
Download Infsect 0.2 (Win32, 36 KB)
Download source code (3.83 KB)
The supplied MS-DOS executable is compiled to run on anything as low as the Intel 8088 CPU, found in IBM XTs. It is recommended that you use MS-DOS 3.30 or later, and have 256KB of RAM or more. The Win32 executable requires Windows 95, Windows NT, or later.
How to Use
If you type infsect -h (or no switches at all), this message is displayed:
INFSECT Version 0.2 Released to the public domain Usage: infsect [file] -s [section] [-g | -i | -d] [field | field=value] infsect [file] -k [section] General switches: [file] Name of file -s Section name -g Read or write field value (trail with =value to write) -d Delete a field -i Interactive prompt to input value Alternate switches: -k Delete a section Program information: -h Display this usage reference
Use of this program requires at least some understanding of the structure of INF files or anything else this covers. As for how this program is used, it would be best to look at some examples...
We'll use this sample file to experiment with the tool:
[version] Signature = "$CHICAGO$" SetupClass = BASE [SectionOther] FamilyValues = NO ; Comment ;Ignore = YES DoNotIgnore = huh?, UNACCEPTABLE [Section] Value = Value1 Quote = "C:\WINDOWS\INF;C:\WINDOWS\OPTIONS\CABS" [OtherSection] Value = Value2 Which = C:\WINDOWS [Lousy] Standalone
Retrieve a value
Here, I want to retrieve the value stored in the field Value at [Section]. To do this, I type:
infsect test.inf -s section -g value
and this is returned to standard output:
Note that Infsect is not case sensitive when it comes to specifying the names of sections or fields, respecting the case insensitive nature of Windows. As such, you can type a section name in all lowercase letters even if it uses title casing.
If you were to try to retrive the value from the field Ignore in [SectionOther], it would not be picked up because the field is cancelled out by a semicolon comment marker. 
If a field contains a value surrounded by quote marks, the quote marks are returned alongside the value.
infsect test.inf -s section -g quote
Assign a new value
To put a new value in a field, the same -g switch is used, but this time the field name is immediately followed by an equals symbol (=). This tells the program you intend to overwrite an existing field with a new value, or create a new field.
To create a new field NewVal storing the value Purplefish, you would type:
infsect test.inf -s section -g NewVal=Purplefish
If you check the file now, [Section] will look something like this:
[Section] NewVal = Purplefish Value = Value1 Quote = "C:\WINDOWS\INF;C:\WINDOWS\OPTIONS\CABS"
To overwrite the value in Value with BrandNew, type:
infsect test.inf -s section -g value=BrandNew
and the section will look like this:
[Section] NewVal = Purplefish value = BrandNew Quote = "C:\WINDOWS\INF;C:\WINDOWS\OPTIONS\CABS"
Note that while it knows to overwrite Value in title casing even when typing value in lowercase, Infsect also changes the casing of the field name to what the user specifies. Also keep in mind that there must be NO whitespace surrounding the equals sign.
To enter a value with spaces surrounded by quote marks, you type:
infsect test.inf -s section -g Value="\"Brand New\""
\" is an escape character for a literal quote mark. The two escape quotes should be sandwiched inside the outermost standalone quote marks, which are used to actually tell the program you're writing a single argument. You can also write the command like this if desired:
infsect test.inf -s section -g "Value=\"Brand New\""
You can also create a new section by adding a field to it, like this:
infsect test.inf -s newsect -g twest -v ok
Prompt user to assign new value
Instead of dealing with extra programs like PUTINENV, you can tell Infsect to prompt the user for a value to assign when you call the program from a batch script. You can type something like this:
infsect test.inf -s section -i Value
When run this way, the user is given the above message and must type a new value themselves before proceeding.
If the user inputs egg, that becomes the new value of Value. If no value is entered, the existing one remains unaffected. If you want to use a default value when the user enters nothing, you'd type something like this:
infsect test.inf -s section -i Value=salad
This ensures that the value salad will be entered if the user doesn't input anything.
Delete a field
To delete a field outright, replace -g with -d followed by the field name, like this:
infsect test.inf -s section -d Value
Obviously, Infsect has to get back up to par with what it was earlier. The "start small" approach worked very well and may be enough for most people, but just in case, I might want to add more things to it like the ability to manipulate subvalues within values later on when I get the time.
Now that Infsect is in a decent position, it'll also allow me to bring about a really cool guide in the future which will need this program. Beyond that, it's not much, but it's a small victory in the way of getting myself into the kind of programming I want to do.
1 Currently, Infsect does not actually skip comments. This will be addressed in a future release.
252 unique views here since February 11, 2021