Skip to content

Instantly share code, notes, and snippets.

@rldutch1 rldutch1/ports.cmd
Created Jun 20, 2014

What would you like to do?
Show Open Ports in Windows
@echo off
REM Author: Robert Holland
REM Creation Date: 10 June 2001
REM Purpose: This script will show what TCP and UDP ports are listening and show what programs are listening on those ports.
REM It will also show the TCP and UDP connections that are established on the computer and what programs are connected.
REM Just match the PID (Process ID’s) to find out what programs are using the ports.
REM The ports will be listed above the dashed line and the programs will be listed below.
REM Robert Holland
@echo Open ports and running applications for %computername% > %computername%.Ports.txt
netstat -ano >> %computername%.Ports.txt
@echo.>> %computername%.Ports.txt
@echo.>> %computername%.Ports.txt
@echo "———————————————————————————" >> %computername%.Ports.txt
@echo "——————programs that are listening are listed below. Just match the PID from above.——————-" >> %computername%.Ports.txt
@echo "———————————————————————————" >> %computername%.Ports.txt
tasklist /svc >> %computername%.Ports.txt
call notepad %computername%.Ports.txt
REM find /I "Listening" %computername%.Ports.txt >> %computername%.Listening.txt
REM find /I "Established" %computername%.Ports.txt >> %computername%.Established.txt
REM find /I "Listening" %computername%.Ports.txt >> \\servername\sharename\%computername%.Listening.txt
REM find /I "Established" %computername%.Ports.txt >> \\servername\sharename\%computername%.Established.txt
REM End of Script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.