Using variables with spaces crashes batches
Posted: 01 Jul 2010 14:19
Hi, I was trying to create something using batch and I keep running into this same annoying bug... If I tell the batch to do something with a variable that has spaces in it, it doesn't work. It's very hard to explain, so I will just show you an example of what I am doing:
These are two lines from my batch file, and whenever it gets to the %command% part, if there is a space in the variable the whole batch closes. This seems unavoidable and is preventing me from going any further. Is there a way to avoid this? I've tried using quotations, but that only seems to give me syntax errors.
Code: Select all
set /p command="Enter a command: "
%command%
These are two lines from my batch file, and whenever it gets to the %command% part, if there is a space in the variable the whole batch closes. This seems unavoidable and is preventing me from going any further. Is there a way to avoid this? I've tried using quotations, but that only seems to give me syntax errors.