Page 1 of 1

String to a batch command problem

Posted: 29 Mar 2010 18:36
by Terraformer

Code: Select all

@echo off
break off
title Ultra's CMD
set /a i=0
cls

echo LOADING...
IPCONFIG |FIND "IP" > %temp%\TEMPIP.txt
FOR /F "tokens=2 delims=:" %%a in (%temp%\TEMPIP.txt) do set IP=%%a
del %temp%\TEMPIP.txt
set IP=%IP:~1%
echo %IP% >%temp%\ip.txt

cls
echo ____________________________WELCOME TO ULTRA'S CMD______________________________
echo ---------------------------------Information------------------------------------
echo COMPUTER NAME  : %computername%
echo COMPUTER IP    : %IP%
echo ________________________________________________________________________________
goto setcommand

:setcommand
set /a i=i+1
if %i% == 6 goto clear
echo.
set /p command=:

if %command%.==. goto setcommand
%command%
if %command% == cls goto clear
goto setcommand

:clear
cls
set /a i=0
echo ____________________________WELCOME TO ULTRA'S CMD______________________________
echo ---------------------------------Information------------------------------------
echo COMPUTER NAME  : %computername%
echo COMPUTER IP    : %IP%
echo ________________________________________________________________________________
goto setcommand


Whenever I include a space in my string, the command does not work and batch crashes. I'm trying to call on the command indirectly using the user's string input. The problem occurs after :setcommand. For example:
When I input and set the %command% variable to "start" everything works fine.
When I input and set the %command% variable to "start /max" my batch window just closes.
Any idea how to get rid of this problem?

Re: String to a batch command problem

Posted: 30 Mar 2010 10:51
by aGerman
Try to use quotes

Code: Select all

set /p "command=:"

if "%command%"=="" goto setcommand
%command%
if "%command%"=="cls" goto clear


Regards
aGerman

Re: String to a batch command problem

Posted: 07 Apr 2010 07:54
by ---saster---
or maybe

["%command%"]==[""] goto setcommand