Pinging & IP addresses plus findstr thrown in

August 30, 2010 at 02:49:57
Specs: Multiple OS, -
You can put an IP address in with "ping -a" (gives you IP computer name)
It does this:
Pinging "Computer" [*.*.*.*] with 32 bytes of data:
Reply from *.*.*.*: bytes=32 time<1ms TTL=128
Reply from *.*.*.*: bytes=32 time<1ms TTL=128
Reply from *.*.*.*: bytes=32 time<1ms TTL=128
Reply from *.*.*.*: bytes=32 time<1ms TTL=128

Ping statistics for *.*.*.*:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

Can it be possible to get the just "computer" [*.*.*.*] from the first line and put it into ether a variable or a file?? using findstr...
I work at a school where i can ping the IP address to see if the computer is working BUT we dont find he computers by IP address... we use the computer name.
Any help will be great! Thanks

See More: Pinging & IP addresses plus findstr thrown in

Report •

August 30, 2010 at 05:04:44
Try This:


FOR /f "tokens=2* delims= " %%a IN ('PING /a IPADDRESS') DO (
	SET Variable=%%a
	GOTO Done


ECHO %Variable%

Good Luck

Can I put a question here?

Report •

August 31, 2010 at 23:52:31
Works great!


Report •

September 3, 2010 at 11:39:38
Sounds like you might benefit from something I wrote a while back for work. Basically this used dsquery (assuming you're in an AD environment) to query a portion of the computer name, pings those computers that are returned by the dsquery search, and shows whether each is online or not.

This allows me to not only find a computer with only a portion of the name but also see whether it's up or not (in a list format) and go from there. I added it to my system path as pingf.bat and simply call it by typing "pingf comp" where comp is a partial computer name. I've ended up using it on a daily basis:

@echo off
Ping -w 150 %1
IF %errorlevel% NEQ 0 GOTO LOCATE


Del /f /q status.txt
Del /f /q comps.txt
Echo Computer names similar to your entry:
DSQUERY computer -limit 250 -name *%1* -o rdn >>comps.txt

for /f %%a in (comps.txt) do (
ping %%a -n 1 -w 100 >nul
if !errorlevel! equ 0 (Echo %%a - Online >>status.txt.) else Echo %%a - Offline >>status.txt.

type status.txt
Echo For more results - please try again with a more broad computer name.

Report •
Related Solutions

Ask Question