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?
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.
You cannot have spaces before or after the equal sign. Try this instead:
set test=zzz
echo %test%
You have to omit the spaces
I used:
set "test=zzz"
and when I used echo %test%
it displays zzz