Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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:


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

share|improve this answer

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

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

You have to omit the spaces

I used:

set "test=zzz"

and when I used echo %test% it displays zzz

share|improve this answer

Your Answer


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.