121 lines
4.1 KiB
Plaintext
121 lines
4.1 KiB
Plaintext
INIFILE - 32 bit tool, Ver 1.6 (c) 2006-2009, Horst Schaeffer
|
|
-------------------------------------------------------------
|
|
|
|
This tool handles Windows type INI files with section names in square brackets,
|
|
and assignments of the form: item=string (case ignored for section and item names).
|
|
The INI file must exist!
|
|
This program uses the functions supplied by the Microsoft Windows API.
|
|
|
|
++++ Change or add an assignment
|
|
|
|
Syntax: INIFILE inifileName [section] item=string
|
|
|
|
Example: INIFILE c:\some\where\program.ini [Profile] Name=John
|
|
|
|
The string is taken up to the end of the line.
|
|
Optionally, the (entire!) assignment may be enclosed in (double) quote marks
|
|
(in case there are redirection symbols in it).
|
|
In any case the item name as well as the string will be taken without leading
|
|
and trailing spaces.
|
|
|
|
Example: INIFILE c:\some\where\program.ini [Profile] "Name = John"
|
|
|
|
If the item is not found, a new line will be added.
|
|
If the section is not found it will be generated.
|
|
|
|
|
|
++++ Remove assignment
|
|
|
|
To remove an item: omit the string (the equal sign is mandatory)
|
|
|
|
Syntax: INIFILE inifileName [section] item=
|
|
|
|
Example: INIFILE c:\some\where\program.ini [Profile] Name=
|
|
|
|
The complete item (not just the assigned string) is removed.
|
|
If there are no items left, the section will NOT be removed.
|
|
No error will be reported (Errorlevel), if the item does not exist.
|
|
|
|
++++ Clear assignment
|
|
|
|
If you want to produce an empty assignment without removing it,
|
|
use two equal signs.
|
|
|
|
Syntax: INIFILE inifileName [section] item==
|
|
|
|
|
|
++++ Remove entire section
|
|
|
|
To remove a section the security option /REMOVE (case ignored)
|
|
is required. No error reported, if the section does not exist.
|
|
|
|
Syntax: INIFILE inifileName [section] /remove
|
|
|
|
|
|
++++ Get an assignment
|
|
|
|
Syntax: INIFILE inifileName [section] item
|
|
|
|
(Note that an additional equal sign would remove the item!!!)
|
|
|
|
The program will generate a SET statement, and send it to STDOUT.
|
|
If you want to produce an environmental variable, redirect the output
|
|
to a temporary batch file, and execute it (see also: GetOutput.txt)
|
|
Note: Character set is ANSI (Windows), not OEM (DOS).
|
|
|
|
Example:
|
|
INIfile c:\some\where\program.ini [Profile] Name > temp.bat
|
|
call temp.bat
|
|
|
|
If the assignment could not be found for any reason,
|
|
the SET statement will be empty (set var=), which clears the variable.
|
|
|
|
Note: This method cannot be used when equal signs or redirection
|
|
symbols are expected in the assigned string.
|
|
|
|
++++ Get all assignments of a section
|
|
|
|
Syntax: INIFILE inifileName [section]
|
|
|
|
SET statements will be generated for all items in the section.
|
|
|
|
|
|
++++ Errorlevels
|
|
|
|
Errorlevel > 0 indicates an error (message to STDERR)
|
|
0 done
|
|
1 INI file does not exist
|
|
2 Section name in square brackets was not given
|
|
255 No INI file specified or help requested (/?)
|
|
|
|
The INI file operations are done through the Windows API which handles spaces,
|
|
upper/lower case etc.. There may be a size limit or a problem with long file
|
|
names in older Windows versions. Please test.
|
|
|
|
Note: In case you have used my old DOS program "INIFILE.COM" make sure that this new
|
|
version is found through your PATH assignment (or use the command "inifile.exe").
|
|
|
|
++++ History
|
|
|
|
version 1.6, 27 May 2009: Compiled with PB 4.30
|
|
version 1.5, 29 Sep 2006: Equal signs allowed in assigned string (though not recommended)
|
|
version 1.4, 02 Aug 2006: Added function: clear assignment without removing
|
|
version 1.1, 12 Feb 2006: Added: read all items of section
|
|
version 1.0, 05 Feb 2006
|
|
|
|
++++ Disclaimer, Copyright
|
|
|
|
This program is distributed as "freeware", copyright reserved by the
|
|
author. There are no warranties of any kind, nor any liability by
|
|
the author. Users accept full responsibility for the use they make
|
|
of the software and for any damage caused thereby.
|
|
|
|
Source available: http://www.horstmuc.de/source/inifile16.zip
|
|
|
|
Contact the author:
|
|
|
|
mailto:horst.schaeffer@gmx.net
|
|
http://www.horstmuc.de/
|
|
|
|
|
|
*** 27 May 2009 |