1.

Solve : geting remot computers name [plaese help]?

Answer»

How do i get the name of a remote COMPUTER???
If it is in a Network with dhcp and you have the ip adress you can use:

nslookup [ipadress]

You can also try something with the pstools from sysinternals.

With psexec it is possible to start a programm on a remote pc.
You can make a batch to give out the variable "computername" and start it on the remote computer; from your machine.

(I didn't try it myself.)

PLEASE post your solution.

hope it helps
uli
Quote

How do i get the name of a remote computer???

some of the tools in WINDOWS that can be used are nbtstat (LAN), nslookup.. you can also find those GNU tools like dig that can query DNS and run them from windows ...


i know i need to do this with a for loop but i can't quite figer out the for loops but i need it to return the name of the computer of the ip i set to a varable = name
so it is like

for nslookup %ip%|find /i name set = name
but i need it only to select to ip when it does the find so if the name on ip = 135.1.65.7 test it would display test insted of name: test
PLEASE HELP THINK YOU VERY MUCH

can you try and see if this WORKS

@echo off
for /F "tokens=2 delims=: " %%i in ('nslookup %ip% ^| findstr /I name') do (
echo %%i
set name=%%i

)Or this:

for /f "tokens=2" %%a in ('"ping /a /N 1 %ip%|find "Pinging""') do echo.%%a

Quote
can you try and see if this works

@echo off
for /F "tokens=2 delims=: " %%i in ('nslookup %ip% ^| findstr /I name') do (
echo %%i
set name=%%i

)

ok now how do i make this not retun an error?? if the ip is not found :-? :-? :-?
Perhaps place some ERRORLEVEL checking in there ?

See attached list (it might help).
for /f "tokens=2" %%a in ('"ping /a /n 1 %ip%|find "Pinging" [highlight]2>NUL[/highlight]"') do echo.%%a[/b]

or

@echo off
for /F "tokens=2 delims=: " %%i in ('nslookup %ip% ^| findstr /I name [highlight]2>NUL[/highlight]') do (
echo %%i
set name=%%i
)


Like this?


Discussion

No Comment Found