-1

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
Javran
  • 3,394
  • 2
  • 23
  • 40
Raziye
  • 33
  • 1
  • 1
  • 8

3 Answers3

5

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.

tripleee
  • 175,061
  • 34
  • 275
  • 318
2

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

Monacraft
  • 6,510
  • 2
  • 17
  • 29
  • 1
    okey thnx for answering my question but you didnt say me whats the difference bitween !s! and %s% – Raziye Oct 01 '14 at 08:55
0

When you have @echo off at the begening, and you echo a empty var, would get this message. Try to check your echoed vars, ensure them not empty.

lufy
  • 33
  • 5