
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎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}
===========================================================================================================
- Labels:
-
API & Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2020 07:16 PM
I used part of your batch command.
FOR /l %%i in (0,1,255) do ping %NewIP%%%i -n 1 -w 100 | find "Reply"
I don't need it to go to a text file, just on the screen.
Lets only display the IP address that are active
resolve the name.
either use the gateway for the starting address
echo My Gateway: %gw%
for /f %%a in ('powershell Invoke-RestMethod api.ipify.org') do set PublicIP=%%a
echo Public IP: %PublicIP%
=========================
Or my IP address
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip=%%b
set ip=%ip:~1%
echo My IP: %ip%
===========================
for nslookup 192.168.0.99 find Name:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 07:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 07:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2015 03:33 PM
That setting makes it possible to see the data you are pulling from with the FIND "REPLY" statement. Definitely adds all the data into the file but we lose the line by line listing that makes it easy to pull into excel.
It's really not a big deal at all and again THANK YOU for posting this action. I'm stoked that I don't have fire up "angry" anymore to do a quick sweep also.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2015 10:15 PM
FOR /l %%i in (0,1,255) do @ping %NewIP%%%i -n 1 -w 100 | find "Reply" >> C:\PingSweep.txt | ECHO %NewIP%%%i
to:
FOR /l %%i in (0,1,255) do @ping %NewIP%%%i -n 1 -w 100 >> C:\PingSweep.txt | ECHO %NewIP%%%i
by removing this part:
| find "Reply"
This will echo all results into the text file. The results will look like this:
Pinging 192.168.63.1 with 32 bytes of data:
Reply from 192.168.63.1: bytes=32 time=14ms TTL=251
Ping statistics for 192.168.63.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 14ms, Maximum = 14ms, Average = 14ms
Pinging 192.168.63.2 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.63.2:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
I hope this works for you.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2015 09:22 PM
Nonetheless, the absolute only thing I would want to see with this is a listing of all the IPs. Is that possible?
