DHCP IP detector then ping live hosts on it

January 1, 2011 at 20:11:12
Specs: Windows 7
hi all,
i wanted to make batch to detect the DHCP ip "router's ip" and then ping the whole lan to find online hosts on it.
thanks in advance
=======================================================================
batch is the hidden power of computer
=======================================================================

See More: DHCP IP detector then ping live hosts on it

Report •


#1
January 1, 2011 at 20:59:59
Ok.... what i would do is a ipconfig /all and parse out the data and find a router ip and that gives you the ranges you have to look in and then send simple ping requests to each computer in some kind of a for loop and based on the data you getback you can then determine if the host is up or not.

At least thats what i would do if it were a bash script.

You should look into Powershell if your on windows. Much more useful then batch script.


Report •

#2
January 1, 2011 at 21:24:05
ok thx for replying and i typed ipconfig /all command but i still can not see the range of the lan..........any ideas??

Report •

#3
January 2, 2011 at 02:24:45
Try this;

*** UNTESTED ***

::SCRIPT.bat

@echo off
:MAIN
cls
for /f "tokens=15" %%j in ('ipconfig') do set IP=%%j
if %IP%==0.0.0.0 goto FIX
goto DHCP

:FIX
ipconfig /renew
goto MAIN

:DHCP
for /f "tokens=14" %%j in ('ipconfig /all ^| find "DHCP"') do set DHCP=%%j
echo Your DHCP IP: %DHCP%
echo.
echo Press any key to ping the whole IP range for active hosts..
pause>nul
md %TEMP%\Hosts
for /l %%i in (1,1,255) do ping -n 1 %DHCP:~0,9%.%%i > %TEMP%\Hosts\%%i.txt
echo.
echo Done pinging whole IP range
echo.
echo Press any key to open the directory of the results..
pause>nul
start explorer.exe "%TEMP%\Hosts"
exit

Regards,

Happy is ONE who says I am an OttoMAN.


Report •

Related Solutions

#4
January 2, 2011 at 08:04:41
thanks MUs.......u solved my problem by using the:
for /l %%i in (1,1,255) do ping -n 1 %DHCP:~0,9%.%%i command

Report •

#5
January 2, 2011 at 11:10:56
Your'e welcome, and thank-you for the reply.

Regards,

Happy is ONE who says I am an OttoMAN.


Report •


Ask Question