Click here for important information about

Variable in variable

September 11, 2011 at 15:04:45
Specs: Windows 7

As a good programmer should do I am trying to seperate my logic from my data, by using an INI-like file with key value pairs. I'm reading the ini like this:

setlocal disabledelayedexpansion
FOR /F "tokens=1* delims==" %%i IN (%~n0.ini) DO set "%%i=%%j"

This will read an ini-file with the same name as my script name. I can put for instance:


... inside the ini, and I can use variable %foo% anywhere i want inside my script (After it has read the ini-file of course).

Now, I would like to be able to use variables inside my ini-file, like this:

ServerExe=executable.exe %CommandLineOptions%

The script itself will present the user with choices of commandline options, after that %ServerExe% should be executed with a call, but for the sake of testing I echo'd it to my commandline. However, it does not use the value of %CommandLineOptions% as the user just set inside my script, but it uses the litteral string as declared inside my ini. So, exactly this:

executable.exe %CommandLineOptions%

... is displayed, including the percentage signs.

I hope my story is clear...

Is there a solution to this?

See More: Variable in variable

September 11, 2011 at 15:36:24

Report •
Related Solutions

Ask Question