Skip to content

Instantly share code, notes, and snippets.

@rldutch1
Created June 20, 2014 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rldutch1/781367257aacbd6e6e5c to your computer and use it in GitHub Desktop.
Save rldutch1/781367257aacbd6e6e5c to your computer and use it in GitHub Desktop.
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