john
john

Reputation: 23

windows command line evaluate inner variable expression

I want to set environment variables based on a text file. The text file has the following format name=value

In my script i simply iterate the file and perform a set command:

FOR /F "tokens=* delims=" %%A IN ('type test.ini') DO (
    SET %%A
)

The problem is that the text file can contain something like folder=%HOMEPATH%\test

The set command does not evaluate the %HOMEPATH% environment variable. Instead of \Users\john\test the variables value is %HOMEPATH%\test.

Is there a way do accomplish this?

Thanks!

Upvotes: 2

Views: 3450

Answers (1)

Benoit
Benoit

Reputation: 79215

Use: CALL SET %%A then.

CALL will itself expand %%A and then SET will expand %HOMEPATH%.

Upvotes: 1

Related Questions