bat file to show computer ip address issue

piaakit
piaakit used Ask the Experts™
on
Dear All


             i have made below bat file to client desktop, and found that 1 computer showing the wrong ip address after click on the bat file, the ip show the old DC & DNS server, any idea what goes wrong ? any idea to get it fix and showing the real computer ip address ?


@echo off
REM myip.bat
REM script to return just the IP address of the current host.
REM Works on Windows 2000 / Windows XP
COLOR 4f
REM TYPE "FOR /?" AT THE COMMAND PROMPT TO GET DETAILS REGARDING THIS COMMAND LINE.
REM NOTE THE SINGLE BACK QUOTES ARE THE ONES BELOW THE ~ KEY ON THE KEYBOARD.
FOR /F "usebackq tokens=2 delims= " %%i in (`nslookup %computername%`) do set myip=%%i
ECHO.
Echo IP Finder
ECHO -----------------------------------

ECHO My IP Address Is: %MYIP%
Echo.
ECHO My Computer Name Is: %COMPUTERNAME% 
ECHO -----------------------------------
@pause

Open in new window

Keith
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Please go to the computer and do the nslookup command there.
If that command returns the wrong IP address, you should fix it in the DNS server.
Top Expert 2014

Commented:
One possibility for that result is when the client doesn't have a DNS record.  Depending on config, the fix could be any of the following:
 - creating a static record
 - running ipconfig /renew
 - running ipconfig /registerdns
 - wait (the client could automatically register its record, or renew its DHCP lease with DHCP registering the record)

Author

Commented:
the actual ip of the computer should be 10.141.103.153, but when clicking the bat file is show 10.141.101.5

Commented:
But you didn't actually answer the questions.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial