PortQry - Simple Command Line Port Scanner

Monday, November 22, 2010
There are many reasons why you may need to use a port scanner to check if a TCP or UDP port is open.  Microsoft has a little known utility called PortQry that allows you to perform basic port scanning from the command line.

You can download PortQry from http://www.microsoft.com/downloads/en/details.aspx?familyid=89811747-c74b-4638-a2d5-ac828bdc6983&displaylang=en

Download the PortQryV2.exe package and run it to extract the PortQry.exe program, EULA and readme file.  I typically copy PortQry.exe to my %SystemRoot% folder so I can run it from any directory.

Here are some examples of how to use PortQry from the command line:
  • portqry -n servername -e 80  -  Queries remote computer servername to check if it's listening on TCP port 80 (HTTP).
  • portqry -n servername -p UDP -o 37,88,135  -  Queries the remote computer to check if it's listening on UDP ports 37, 88 and 135.
  • portqry -n  -r 1-1024  -  Queries the IP address to determine if it's listening on any of the well-known TCP ports.  The output will display each port and whether it's listening or not listening.
  • portqry -n -r 1:1024 | find ": LISTENING"  -  Same as above, but only lists open ports.
PortQry can also be run in silent mode using the -q switch.  The program exit with a returncode of 0 if listening, 1 if not listening, or 2 if listening or filtered.  This is useful for batch file processing.

1 comment:

  1. PortQry is useful for power users, but it can be complex and cumbersome for non-techies. For a web based service that is simple to use, try http://www.firebind.com

    Firebind has a java based client that allows a user to test for TCP or UDP blocked ports. It can test any of the 65535 TCP or UDP ports to see if the client machine can use a given port (or range of ports) to reach the Internet.

    It's not a port scanner.... Think of it more as a path scanner.


Thank you for your comment! It is my hope that you find the information here useful. Let others know if this post helped you out, or if you have a comment or further information.