开发者

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 accomp开发者_运维百科lish this?

Thanks!


Use: CALL SET %%A then.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜