Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Via a *.cmd script I do set "test = zzz" at the command line and then "echo %test%" and what's echo'd back to me isn't zzz, as I'd expect, but %test%.

Any ideas?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Your invocation of the set command actually works, but it doesn't do what you expect.

The command prompt treats the spaces surrounding the equality sign (=) literally. As a result, the command sequence

set test = zzz
echo %test%
echo %test %

prints the following:

%test%
 zzz

Since the variable test is unset, %test% doesn't get replaced.

share|improve this answer
add comment

You have to omit the spaces

I used:

set "test=zzz"

and when I used echo %test% it displays zzz

share|improve this answer
add comment

You cannot have spaces before or after the equal sign. Try this instead:

 set test=zzz
 echo %test%
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.