batch file ERROR which says ECHO IS OFF [duplicate]

i have written this batch file code but it has this error i appreciate u if answer me .

the error is that when i choose 2 it gone to ask me to enter desire site but when i write the address it has an error says ECHO IS OFF

HELP ME WHAT SHOULD I DO...

@echo off
title trace
:main
echo 1)TRACE GOOGLE
echo 2)TRACE YOUR SITE
set /p choice=          Enter your choice:
echo %choice%
if %choice%==1 ( 
  tracert www.google.com
  goto main
  pause >nul
)
if %choice%==2 (
  set /p s=Enter your desired site:
  echo %s%
  pause >nul
)
pause >nul

It's not an error message, it's what happens when you run echo without arguments. In other words, you see this because %s% winds up being empty.


To fix your problem use enabledelayedexpansion as in a block % will expand to the value prior to the block:

@echo off
setlocal enabledelayedexpansion
title trace
:main
echo 1)TRACE GOOGLE
echo 2)TRACE YOUR SITE
set /p choice=          Enter your choice:
echo %choice%
if %choice%==1 ( 
  tracert www.google.com
  goto main
  pause >nul
)
if %choice%==2 (
  set /p s=Enter your desired site:
  echo !s!
  pause >nul
)
pause >nul

Which should work