0

I've been trying to create a program that tell you your IP on any computer. Yet An Error has been coming up.

@echo off
set t=%CD%\file.txt
ipconfig >>file.txt
find /v "IPv4 Address . . . . . . . . . . . :" "%t%" >>Other_Details.txt
find /n "IPv4 Address. . . . . . . . . . . :" "%t%" >>YourIpAddress.txt
(
Set /p 1=
Set /p 2=
Set /p 3=
)<YourIpAddress.txt
echo %3%
pause

And then this pops up when I run It:

Echo Is Off

plz help

1
  • Do you want the LAN IP address or the WAN IP address?
    – foxidrive
    Commented May 18, 2014 at 8:26

2 Answers 2

1

A way to suppress this message is to use

echo(%var%

if var may not be set.

There is however an error in your code.

%n where n is 0..9 means "the parameter supplied to the routine in position n". Hence were you to run mybatch one two three then %0 would be mybatch, %1 would be one, %2 two and %3 three. %4 to %9 would be empty.

It is possible to set an environment variable named 0..9, but retrieving such data is a little more tricky. User-variables should simply not start with a numeric.

1
  • "User-variables should simply not start with a numeric." THIS. +1 Commented May 18, 2014 at 17:31
1

%3% apparently is empty. If that is the case, then the line echo %3% actually translated to just echo. Calling echo without parameters makes it echo the current echo state. So it's not really an error message.

To fix it, use a dot after echo:

echo.%3%

That doesn't change the fact though that %3% is empty.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.