Windows echo command can't echo a user-set variable

jacobsee picture jacobsee · Dec 10, 2009 · Viewed 64.3k times · Source

What did I do to screw up my CMD shell? Windows XP Pro, open a cmd window and do:

C:\>set tt = name

C:\>set tt
tt = name

C:\>echo %tt%
%tt%

C:\>echo %time%
14:13:28.67

The echo command doesn't work for some reason. I can echo the built-in variables just fine. Tried it on another computer and that works as expected

Answer

akf picture akf · Dec 10, 2009

The set command does not take spaces. The proper syntax would be:

set tt=name

What you have done in your example is set an environment variable tt<space>. With that in mind, you can try this:

echo %tt%

and see your output.