Reputation: 47124
I have this little batch script:
SET @var = "GREG"
ECHO %@var%
PAUSE
When I run it, it prints:
H:\Dynamics>SET @var = "GREG"
H:\Dynamics>ECHO
ECHO is on.
H:\Dynamics>PAUSE
Press any key to continue . . .
Why won't it print the contents of @var? How do I know if @var is even being set?
Upvotes: 83
Views: 282165
Reputation: 1
Im new to this but maybe trying semicolon at the end of declaring the variable?
SET @var="GREG":
ECHO %@var%
PAUSE
Upvotes: -2
Reputation: 2630
Try the following (note that there should not be a space between the VAR
, =
, and GREG
).
SET VAR=GREG
ECHO %VAR%
PAUSE
Upvotes: 32
Reputation: 21209
Dont use spaces:
SET @var="GREG"
::instead of SET @var = "GREG"
ECHO %@var%
PAUSE
Upvotes: 176