Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Laraso
- Posts: 1
- Joined: 01 Jul 2010 14:09
#1
Post
by Laraso » 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:
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.
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 01 Jul 2010 15:17
Laraso wrote: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.
Hmm, not for me. I tried
net help and it worked fine.
Would you give an example command, please.
Regards
aGerman
-
alan_b
- Expert
- Posts: 357
- Joined: 04 Oct 2008 09:49
#3
Post
by alan_b » 01 Jul 2010 15:50
I suggest you try this :-
Code: Select all
set /p command="Enter a command: "
ECHO %COMMAND%
%command%
Launch CMD.EXE, run the script and enter whatever you chosen command is,
the right click the display and choose "Select All", then hit ENTER to copy the screen to the paste buffer. Then reply here and use Ctrl'V to copy the paste buffer into the reply so we can see what your problem is.
Alan