We have a batch file which is in turn compiled into an exe before usage. We are changing the batch file so that it reads from an ini file to get the settings that it requires... (rather than recompiling the exe each time)...
I've had no problem setting this up so that it can read the ini file, but seem to have staggered across a problem if there are any spaces. My code is as follows:
Type %SDQINIFILE% | find %SDQ_Version% > %SDQQUERYFILE%
For /f "tokens=1-3 delims== " %%d in (%SDQQUERYFILE%) do set SDQ_Version=%%e
In the above sample the variables are as follows:
%SDQINIFILE% is the location and name of the INI file it should read
%SDQ_Version% is the text it should look for, which in this case would be "SDQ_Version="
%SDQQUERYFILE% is the location and name of the temporary results file
This is fine, and would return the current version (i.e. v3.1) once the variable is called later in the script... However, some of the INI lines are going to require spaces in it... i.e. it's going to return a file location, or a name of something...
As there is no way to tell how many words/spaces there will be in the answer, I'm a bit stuck as to how to approach this one, as it won't follow the 3 items rule (NAME=VALUE)...
i.e. SDQ_MAINMENUFIX1_NAME=Reset MS-Office User Info
If we were to apply my code above, it would return a value of "Reset"...