JSI Tip 8389. Resolve script returns the IP Address, DNS name, and NetBIOS name of a computer.

Jack Kress has provided Resolve.bat to return the IP Address, DNS name, and NetBIOS name of a computer.

When I type resolve jsi001, I receive:

IP ADDRESS =   216.144.1.25
DNS NAME =     jsi001.jsiinc.com
NETBIOS NAME = JSI001
When I type resolve 216.144.1.25, I receive:
IP ADDRESS =   216.144.1.25
DNS NAME =     jsi001.jsiinc.com
NETBIOS NAME = JSI001
When I type resolve jsi001.jsiinc.com, I receive:
IP ADDRESS =   216.144.1.25
DNS NAME =     jsi001.jsiinc.com
NETBIOS NAME = JSI001
To process the returned information in a script, you could use:
for /f "Tokens=1,2* Delims

" %%a in ('resolve jsi001') do ( if "%%a" EQU "IP" set IP=%%c if "%%a" EQU "DNS" set DNS=%%c if "%%a" EQU "NETBIOS" set NETBIOS=%%c )

Resolve.bat contains:
@ECHO Off
::Returns a IP, NETBIOS and DNS name from a IP, NETBIOS or DNS name being passed in.
::Syntax: RESOLVE 192.168.1.1
::Syntax: RESOLVE SERVERNAME
::Syntax: RESOLVE SRVR.DOMAIN.COM
::Jack Kress - 2/26/04
:: v3

SETLOCAL
SET SCRIPTNAME=%~n0
IF "%1""" ECHO Incorrect Syntax - use: %SCRIPTNAME% NETBIOSNAME && GOTO :EOF
FOR /F "tokens=3delims=: " %%I IN ('PING -n 1 %1 ^| FIND "Reply from"') DO (
 SET IP=%%I
 FOR /F "tokens=2 delims=:" %%J IN ('NSLOOKUP %%I ^| FIND "Name:"') DO SET DNS=%%J
 FOR /F %%K IN ('NBTSTAT -A %%I ^| FIND "  UNIQUE"') DO SET NETBIO=%%K
)
IF NOT DEFINED IP @ECHO %1 is invalid or NETWORK error occurred. && GOTO :EOF
@ECHO.
@ECHO IP ADDRESS =   %IP%
IF NOT DEFINED DNS @ECHO %1 - invalid DNS name or DNS error occurred. && GOTO :EOF
@ECHO DNS NAME = %DNS%
IF NOT DEFINED NETBIO @ECHO %1 - invalid NETBIOS name or WINS error occurred. && GOTO :EOF
@ECHO NETBIOS NAME = %NETBIO%
ENDLOCAL



TAGS: Windows 8
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish