So basically, I have a script we use out on the field to do various functions. Part of the script will include a 'Debug Terminal' (For setting and checking variables, running functions directly etc.). I ran into some problems initially with echo and set commands (echo Hi would result in Hi is not recognized..; set would not process).
Here's what I wound up with:
:DebugConsole
%title%Debug Console %end%
:DebugConsoleTop
echo.
echo Enter a command or type 'exit' to finish.
set /p ConsoleInput=
if "%ConsoleInput%"=="exit" (
goto DebugConsoleEnd
)
:if set used
if "%ConsoleInput:~0,3%"=="set" (
echo %ConsoleInput%> "%datapath%\debugcmd.txt"
set /p ConsoleOutput=<"%datapath%\debugcmd.txt"
del /f "%datapath%\debugcmd.txt"
) else (
:if echo
if "%ConsoleInput:~0,4%"=="echo" (
set "echofix=echo echo"
::set ConsoleInput=%ConsoleInput:%echofix%=%
call set ConsoleInput=%%ConsoleInput:echo=%echofix%%%
%ConsoleInput%
goto DebugConsoleTop
)
:all else
FOR /F "delims=" %%i IN ('%ConsoleInput%') DO (
SET ConsoleOutput=%%i
echo %ConsoleOutput%
pause
)
)
%ConsoleOutput%
goto DebugConsoleTop
:DebugConsoleEnd
cls
exit /b
The problem I'm facing now is that you can not echo variables correctly. If I input "set var=test" and then "echo %var%" the output is "%var%" and not "test". However, if I input "%var%" i receive "test is not recognized.."