‎11-05-2015 08:07 PM - last edited on ‎04-01-2024 04:32 PM by Mercedes_O
I got tired of hunting down and running "Angry IP" every time I wanted to Ping Sweep a subnet, so I put together this command file that can be called from an assets screen. It uses the Windows CMD environment to Ping Sweep the subnet that the asset is on. It writes all found IPs to C:\PingSweep.txt, then opens the file when it is finished. While performing the ping sweep, it echos the IP addresses being pinged to the screen so you can watch its progression.
FIRST: create a command file named PingSweep.cmd and add the following lines to it, (I am attaching this file as well)
@ECHO OFF
CLS
REM Call this command file passing the full IP Address of a network device,
REM i.e. Pingsweep 192.168.1.1
REM Set the Variable "IP" to the IP range passed to the CMD file. This needs to be done
REM because parsing the sub-net from the passed variable does not work.
REM *************************************************************************************************
Set IP=%1
REM Parse the subnet to the "NewIP" variable.
REM this takes each class range of the IP address using the "." as the delimiter
REM and assigns it to the String "NewIP" and adds the necessary "." back in
REM so that the subnet is recreated properly regardless of the subnet IP structure.
REM This does however assume you are pinging a class C network.
REM *************************************************************************************************
FOR /F "tokens=1,2,3* delims=." %%a in ("%IP%") do set NewIP=%%a.%%b.%%c.
REM Echo the Subnet being scanned, and pause to allow continuation or cancel of the PingSweep command.
REM *************************************************************************************************
ECHO The SubNet being scanned is: %NewIP%
REM Give the choice to continue the PingSweep or exit
REM *************************************************************************************************
:menu
CHOICE /C YN /M "Do you wish to Ping Sweep this network?"
IF ERRORLEVEL 2 GOTO Exit
IF ERRORLEVEL 1 GOTO PingIt
REM If not the right subnet, then exit
:Exit
exit
:PingIt
REM Ping the subnet from "0" to "255" showing only those devices who "Reply"
REM the "0" and "255" will return the providers IP address. You can use whois.arin.net to
REM find the service provider. For example 63.232.116.198 returns
REM Quest Communications Company
REM *************************************************************************************************
CLS
ECHO The first and last IP's returned reflect the Internet Providers address. >C:\PingSweep.txt
ECHO You can use whois.arin.net to find the service provider. >> C:\PingSweep.txt
ECHO For example 63.232.116.198 returns Quest Communications Company >> C:\PingSweep.txt
ECHO ************************************************************************** >> C:\PingSweep.txt
ECHO : >> C:\PingSweep.txt
ECHO PLEASE WAIT WHILE THE C:\PINGSWEEP.TXT FILE IS BEING CREATED
ECHO IT WILL BE AUTOMATICALLY OPENED WHEN THE SWEEP IS FINISHED
ECHO *************************************************************
FOR /l %%i in (0,1,255) do @ping %NewIP%%%i -n 1 -w 100 | find "Reply" >> C:\PingSweep.txt | ECHO %NewIP%%%i
START Notepad.exe "C:\PingSweep.txt"
============================================================================================================
SECOND: Save this file into the Lansweeper "Actions" folder.
Create a new action called PingSweep and add this Action:
{actionpath}PingSweep.cmd {ipaddress}
===========================================================================================================
‎12-23-2020 07:16 PM
‎12-13-2016 07:33 PM
‎12-13-2016 07:13 PM
‎12-03-2015 03:33 PM
‎12-02-2015 10:15 PM
‎12-02-2015 09:22 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now