The clini utility is a command line INI utility that writes information to and reads information from an INI file, and merges information from one INI file with another.
In addition to setting values, the clini utility can append values to existing items in an INI file. By default, no delimiter is used to append values. A delimiter can be specified, if required. Appending values provides the ability to build values in the INI file by issuing multiple commands. When reading values from an INI file to set an environment variable, the values can be tokenized to specify a particular token.
The clini utility checks the number of characters on the command line and displays a message if the characters exceed the limit. The /O parameter overrides character-limit checking.
clini <filename> <[filename2 [/ES] [/A|/U|/P]]> <[/S:section] [/I:item] [/V:value|/A:value|/U:value|/E:variable |/=:string|/C:string|/CT:string]> [/B:file_name] [/D:delimiter] [/T:n] [/R] <[/CMT|/UCMT| [/AI] [/CC:character]]> [/NS] [/N] [/O]
Parameter | Description |
---|---|
filename |
Defines the fully qualified path to the INI file to process. |
filename2 |
|
/ES |
Specifies to merge only the items or values in the empty section. |
/A |
|
/U |
|
/P |
|
/S:section |
Specifies the name of the section within the INI file to write or to read. |
/I:item |
Specifies the name of the item within the INI file to write or to read. |
/V:value |
Specifies the value to write to the INI file. |
/A:value |
|
/U:value |
|
/E |
|
/E:variable |
|
/=:string |
Verifies that the value of the item is equal to string, returning a value of 0 if true and 100 if false. |
/C:string |
Verifies that value of the item has string as a substring, returning a value of 0 if true and 100 if false. |
/CT:string |
|
/B:filename |
|
/D:delimiter |
|
/T:n |
|
/R |
Removes the specified section, item, or value from the INI file. Removing the last item in a section also removes the section. |
/CMT |
|
/UCMT |
|
/CC:character |
|
/AI |
|
/N |
Deletes an existing INI file and creates a new INI file. This parameter is not valid with the /E parameter. |
/NS |
Omits spaces around "=" when writing items into INI files. By default, the clini utility concatenates spaces around "=" when writing items. |
/O |
|
Example | Description |
---|---|
clini info.ini /S:Hardware /I:Machine Type /V:8549 /N |
Deletes any existing info.ini file and creates a new INI file named info.ini with a section called Hardware that contains one item, Machine Type, which has a value of "8549." |
clini info.ini /S:Hardware /I:Machine Name /V:Server1 |
Adds the item Machine Name with a value of Server1 to the existing Hardware section of the info.ini file |
clini info.ini /S:Hardware /I:Machine Type /E:MachineType call CLIniSet.bat |
Reads the Machine Type value from the info.ini file, and stores it as an environment variable called MachineType. |
clini info.ini /S:Hardware /I:Machine Type2 /V:%MachineType% |
Writes the value of the environment variable MachineType to the INI file named info.ini, using section Hardware and item Machine Type2. |
clini info.ini /S:Hardware /I:Machine Type2 /E:MachineType2 /B:d:\EnvSet1.bat call d:\EnvSet1.bat |
Reads the machine type value from the info.ini file and stores it as an environment variable called MachineType2 using a custom path and name for the batch file created to set the environment variable. |
Clini info.ini /S:MySection /E Call cliniset.bat |
This example creates environment variables for all the items found in section MySection. |
Clini info.ini /AI /E /B:setthem.bat Call setthem.bat |
This example creates environment variables for all the items found in any section of the info.ini file and uses an alternate name for the CLIniSet.bat file. |
Clini info.ini /S:MySection /I:MyItem /E Call cliniset.bat |
This example creates an environment variable called My_Item if it exists in the info.ini file. |
Clini info.ini /S:MySection /I:My Item /E /NS Call cliniset.bat |
This example creates an environment variable called My_Item (converts the space to an underscore for the environment variable name) if the item exists in the info.ini file. |
After running the first five examples above, in sequence, the info.ini file contains the following information: [Hardware] Machine Type = 8549 Machine Type2 = 8549 Machine Name = Server1 Also, two new environment variables are created, as shown below:
MachineType = 8549 MachineType2 = 8549 |
|
clini info.ini /S:User /I:Name /V:Toolkit /N clini info.ini /S:User /I:Name /A: User or clini info.ini /S:User /I:Name /V:Toolkit /N clini info.ini /S:User /I:Name /A:User /D:" " |
Creates a new file named info.ini with a section called User and one item called Name, which is set equal to "Toolkit User". The resulting info.ini file contains: [User] Name = Toolkit User |
clini info.ini /S:Section /I:Item /A:Value1 /D:, /N clini info.ini /S:Section /I:Item /A:Value2 /D:, clini info.ini /S:Section /I:Item /A:Value3 /D:, clini info.ini /S:Section /I:Item /A:Value2 /D:, |
Creates a new file named info.ini with a comma delimited list of values. The resulting info.ini file contains: [Section] Item = Value1,Value2,Value3,Value2 |
clini info.ini /S:Section /I:Item /U:Value1 /D:, /N clini info.ini /S:Section /I:Item /U:Value2 /D:, clini info.ini /S:Section /I:Item /U:Value3 /D:, clini info.ini /S:Section /I:Item /U:Value2 /D:, |
Creates a new file named info.ini with a comma delimited list of unique values. The resulting info.ini file contains: [Section] Item = Value1,Value2,Value3 |
clini info.ini /S:Section /I:Item /E:MyEVariable /T:2 or clini info.ini /S:Section /I:Item /E:MyEVariable /T:2 /D:, |
Reads information from the info.ini file created in the previous example, and sets the second value of the item to the MyEVariable environment variable. The resulting CLIniSet.bat file contains: Set MyEVariable=Value2 |
Content of doit.bat: @Echo off clini info.ini /S:Section /I:Item /V:Value1 /N clini info.ini /S:Section /I:Item /=:Value1 if errorlevel 100 goto itsfalse if errorlevel 1 goto error if errorlevel 0 goto itstrue :error Echo Error occurred Goto end :itsfalse Echo It's false Goto end :itstrue Echo It's true :end |
This example creates a file called info.ini with the following content: [Section] Item = Value1 Then it checks to see if the value of Item in [Section] is equal to Value1 and displays a message. After running doit.bat, the follow message is displayed:
It's true |
Content of doit.bat: @Echo off clini info.ini /S:Section /I:Item /V:Value1 /N clini info.ini /S:Section /I:Item /C:alu if errorlevel 100 goto itsfalse if errorlevel 1 goto error if errorlevel 0 goto itstrue :error Echo Error occurred Goto end :itsfalse Echo It's false Goto end :itstrue Echo It's true :end |
This example creates a file called info.ini with the following content: [Section] Item = Value1 Then it checks to see if the value of Item in [Section] contains substring alu and displays a message. After running doit.bat, the follow message is displayed:
It's true |
Content of doit.bat: @Echo off clini info.ini /S:Section /I:Item /V:V1,V2,V3 /N clini info.ini /S:Section /I:Item /CT:V2 if errorlevel 100 goto itsfalse if errorlevel 1 goto error if errorlevel 0 goto itstrue :error Echo Error occurred Goto end :itsfalse Echo It's false Goto end :itstrue Echo It's true :end |
This example creates a file called info.ini with the following contents: [Section] Item = V1,V2,V3 Then it checks to see if the value of Item in [Section] contains token V2 in a comma delimited list and displays a message. After running doit.bat, the follow message is displayed:
It's true |
Clini info1.ini info2.ini |
This example copies all the sections, items, and values from info1.ini into info2.ini. Any existing values for items in info2.ini are replaced. |
Clini info1.ini info2.ini /P |
This example copies all the sections, items, and values from info1.ini into info2.ini. Any values for existing items in info2.ini are kept. Only new items and values are copied over from info1.ini. |
Clini info1.ini info2.ini /S:MySection |
This example copies all the items and values from the section called MySection in info1.ini into the section called MySection in info2.ini replacing any values that may already exist in the section called MySection in info2.ini. |
Clini info1.ini info2.ini /S:MySection /I:MyItem |
This example copies the value from the section called MySection, for the Item called MyItem in info1.ini into the same section and item in info2.ini replacing the existing value in info2.ini if it already exists. |
Clini info1.ini info2.ini /ES |
This example copies all the items and values from the empty section (items and values that are not in a section) in info1.ini into info2.ini replacing any existing Items in the empty section in info2.ini. |
Clini info1.ini info2.ini /A |
This example appends all the values from the sections and items from info1.ini to info2.ini. |
Clini info1.ini info2.ini /U |
This example uniquely appends all the values from the sections and Items from info1.ini to info2.ini if the value does not already exist in info2.ini. |
Clini info1.ini info2.ini /U /D: |
This example uniquely appends all the values from the sections and items from info1.ini to info2.ini using a comma as the delimiter if the value does not already exist in info2.ini. |
Clini info.ini /V:My Ini Line /CMT |
This example comments out the line My Ini Line in the empty section in the info.ini file with a semicolon if the line exists. |
Clini info.ini /S:MySection /V:My Ini Line /UCMT |
This example uncomments the line My Ini Line in the MySection section of the info.ini if the line exists. |
Clini info.ini /I:MyItem /CMT |
This example comments out the line indicated by the item MyItem in the empty section of the info.ini file if the item exits. |
Clini info.ini /S:MySection /I:MyItem /CMT /CC:# |
This example comments out the line indicated by the item MyItem in the section MySection in the info.ini file with a # sign if the item exists. |
Clini info.ini /s:MySection /AI /V:My Value /CMT |
This example comments out the lines indicated by any item that has a value of My Value of all the items in the section MySection in the info.ini file if the item exists. |
Clini info.ini /s:MySection /CMT |
This example comments out the section header indicated by MySection in the info.ini file if the section exists. |