Solved passing varibles from txt to bat

July 10, 2012 at 06:53:24
Specs: Windows 7
I have a batch script with this in the heading.

SET EXPIRE_IN_DAYS=20
SET WARN_IN_DAYS=10
SET DEBUG_SCRIPT=FALSE
SET LOG_SCRIPT=TRUE
SET ADMIN_ACCOUNT=Administrator
SET ACCOUNTS=user,user2

I want to split this out into another config.txt file.

How would i recall the varibles into my original script?

Many Thanks in advance.


See More: passing varibles from txt to bat

Report •


#1
July 10, 2012 at 20:53:11
I'm not clear on what exactly you want to do. Saving the var. values should be easy and straightforward using a "hold file" output from either "set" or "echo", or by saving the first 6 lines of your original batchfile. Maybe you can give an example, or elaborate on your objective... I feel there's another shoe to drop here, Lol!

Report •

#2
July 11, 2012 at 00:16:29
✔ Best Answer
I have resolved like this

My config.ini
1:name:Tom
2:age:21
3:enable:true
etc.....

=============================================
then my .BAT file

Set _InputFile=c:\config.ini
For /F "tokens=1,2* delims=:" %%A IN (%_InputFile%) DO Set config_var%%A=%%C
EndLocal


Report •

#3
July 11, 2012 at 02:17:16
That should work, saving vars to config_var1,2,3 the data "tom","21", "true" respectively. If you need this data to be non-volatile, you will have to save it to a diskfile:
@echo off>holdfile
For /F "tokens=1,2* delims=:" %%A IN (%_InputFile%) DO >> holdfile echo Config_var%%A=%%C

the naming of "holdfile", and recovery and application of its contents, are up to you.


Report •
Related Solutions


Ask Question