43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
To read statements from an INI file you have to capture the output
|
|
of INIfile.exe, which can be done either by ...
|
|
|
|
+ redirecting the output into a temporary file (all Windows versions),
|
|
+ using a FOR /F construct (requires Win2000, XP ++)
|
|
|
|
Assuming you have the INI file "My.ini" in the current directory,
|
|
with a section [Profile], and the item "Name":
|
|
|
|
[Profile]
|
|
Name=John Doe
|
|
|
|
+++ Example with output redirection:
|
|
|
|
INIfile.exe My.ini [Profile] Name > temp.bat
|
|
call temp.bat
|
|
|
|
INIfile.exe outputs the statement: SET Name=John Doe
|
|
which is redirected and written into "temp.bat",
|
|
which is CALLed to run the SET statement.
|
|
|
|
Note that this method produces a temporary file that you have
|
|
to delete later.
|
|
|
|
|
|
+++ Example with FOR construct (asssuming in a batch file):
|
|
|
|
for /f "delims=" %%a in ('INIfile.exe My.ini [Profile] Name') do %%a
|
|
|
|
This will capture and run the output line(s) from the command
|
|
which is enclosed in single(!) quote marks.
|
|
Double quote marks may be used within the command, if necessary.
|
|
For details see FOR /? at the command prompt.
|
|
|
|
|
|
In any case the variable %Name% will hold the string that was assigend
|
|
in the INI file. Note that the variable may be empty.
|
|
|
|
***
|
|
|
|
|
|
|