On Mon, 19 Jul 2004 09:08:19 -0700, "Gerald"
<(E-Mail Removed)> wrote:
>Is there a does command to get a computer name using its
>IP address?
I just scripted IPName.bat for you.
The syntax for using IPName is:
[call] IPName IPAddress Name [/f]
where IPAddress is the IP Address.
Name is a the environment variable name you want returned.
/f is optional and causes the fully qualified name to be returned.
IPName.bat contains:
@echo off
if {%2}=={} @echo Syntax IPName IP Name [/f]&goto :EOF
setlocal
set ip=%1
set Type=C
set Name=NF
if /i {%3}=={/F} set Type=D
for /f "Tokens=2" %%n in ('ping -a -n 1 %ip%^|findstr /i /c:"Pinging"') do (
set Name=%%n
)
if "%Type%" NEQ "C" goto finish
for /f "Tokens=1 Delims=. " %%n in ('@echo %Name%') do (
set Name=%%n
)
:finish
endlocal&set %2=%Name%
Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com