String to a batch command problem
Posted: 29 Mar 2010 18:36
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?