I would like to use a batch script to automate some work that I will give customers. I want to give them an INI file WITH comments (so they understand what they are setting).
Example INI:
[General]
;Set your operating system
OS=Windows7
Read ini from windows batch file Is a good start but does not help with comments.
Thanks in advance.
The FOR statement has the EOL option that specifies a character that indicates the line is to be ignored if it appears in the 1st position on a line. The default EOL character is ;
, so you don't have to do anything special to ignore lines that begin with ;
.
Your requirements are not very clear. I'm not sure what (if anything) you want to do with the section labels like [General]. I'm going to ignore them.
You can use FIND or FINDSTR to filter out any line that does not contain =
.
Here is a simple script that will load variables as defined by the .ini file. Lines that begin with ;
are comments. Section headers are ignored.
@echo off
for /f "delims=" %%A in ('findstr = example.ini') do %%A
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.