BaruchLi
BaruchLi

Reputation: 1103

Concatenate env variable value with string in command line

This is Windows 7 command prompt question.

Suppose I have environment variable which were set in a next way:

set FILE_SRC="D:\Users\me\Documents and Settings"

I would like to call form command line utility which will get one of directory files as argument:

fooUtil.exe %FILE_SRC%\fileName.txt

In this case shell fails to construct correct path string. Instead of it utility get next argument:

"D:\Users\me\Documents and Settings"\fileName.txt

What is a correct way? Again, I talk about prompt command line and not a batch file.

Upvotes: 4

Views: 16995

Answers (2)

nanogrid
nanogrid

Reputation: 41

I make it so ...

set "FILE_SRC=D:\Users\me\Documents and Settings" fooUtil.exe "%FILE_SRC%\fileName.txt"

This works also with special characters.

set "line=lines & edges = figures" @echo "%line%"

Upvotes: 4

Peter
Peter

Reputation: 199

Just skip the quote marks when setting the variable. The variable will be set to the value terminated by a newline, not space.

Upvotes: 2

Related Questions