Batchography: Parsing INI files from a Batch file

Often times you might want to write Batch file scripts to automate system administration tasks, and in addition to that you might want to pass configuration files to your Batch scripts.

This article, inspired by the Batchography book, shows you how to parse INI files and retrieve values from a given section and key.

Quick background

An INI file (or initialization file) is a text file that has the following format:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
; comment
[section_name1]
Key1Name=Value1
.
.
.
[section_name2]
Key1Name=Value1
Key2Name=Value2
.
.
.
; comment [section_name1] Key1Name=Value1 . . . [section_name2] Key1Name=Value1 Key2Name=Value2 . . .
; comment

[section_name1]
Key1Name=Value1
.
.
.
[section_name2]
Key1Name=Value1
Key2Name=Value2
.
.
.

In the MS Windows operating system, a C/C++ programmer can read/write values from the INI files using the following APIs:

But can we do the same using Batch files?

Yes and in the next section, we show you how to read values from the INI file. Continue reading “Batchography: Parsing INI files from a Batch file”

Batchography: Reading a text file line by line in Batch files

This is yet another article about Batch files. In this article, I am going to show you how to read a text file line by line using the Batch files scripting language.

For more advanced Batch scripting topics, please grab a copy of the Batchography book.

batchography-good-res

Let’s get started! Continue reading “Batchography: Reading a text file line by line in Batch files”

7 tips to help you spot Amway / WWDB recruiters in coffee shops

working-in-cofeeshopsIn my previous article “An encounter with Amway / WWDB recruiter” I shared my story about encountering an Amway recruiter.

In this article, I want to give you some tips on how to spot and recognize Amway recruiters so you know what to expect before they waste your time / money.

Continue reading “7 tips to help you spot Amway / WWDB recruiters in coffee shops”