I'm trying to define and use a variable in a batch file. It looks like it should be simple:
@echo off
set location = "bob"
echo We're working with "%location%"
The output I get is the following:
We're working with ""
What's going on here? Why is my variable not being echo'd?
The space before the =
is interpreted as part of the name, and the space after it (as well as the quotation marks) are interpreted as part of the value. So the variable you’ve created can be referenced with %location %
. If that’s not what you want, remove the extra space(s) in the definition.