Article ID: 310513 - Last Review: February 28, 2007 - Revision: 6.2 How to Make Portqry.exe Only Report Listening PortsThis article was previously published under Q310513 On This PageSUMMARY
This article describes how to make Portqry.exe report only ports that are listening and not report ports that are in other states.
Note Version 2 of Portqry.exe is now available. The Microsoft Download Center link at the end of this article has been updated to reflect the new version. Version 1.0 of Portqry.exe has been removed from the Microsoft Download Center. MORE INFORMATION
You can use the Portqry.exe command-line tool to help troubleshoot TCP/IP connectivity issues. Portqry.exe runs on Windows 2000 and later Microsoft Windows operating systems. Portqry.exe reports the port status of target TCP and UDP ports on a computer you select. By default, Portqry.exe reports the status of a port as LISTENING, NOT LISTENING, or FILTERED. When you use the -q (quiet) switch with Portqry.exe, all output to the screen (except error messages) is suppressed. After the target port is queried, Portqry.exe returns one of the following values:
Query.bat Defines What Ports to Query and Calls Listen.bat
:Top @echo off :loop @echo PortQry is querying TCP ports 25,110,143,53, and 389 @echo It will only report which ports are listening @FOR %%I IN (25 110 143 53 389) DO CALL listen.bat %%I :end Listen.bat Calls Portqry.exe and Passes it the Target PortNOTE: Only the ports that are found listening are reported.
:Top
Copy the text of each of the preceding batch files, paste this text into a text file, and then save these files as Query.bat and Listen.bat. Copy these files into the same folder that contains Portqry.exe, and then run Query.bat. Edit the list of ports in the Query.bat file, as well as the protocol that is used and the target server in the Listen.bat file to change the functionality as needed.@echo off @portqry -n myserver.reskit.com -e %1 -p tcp -q @if errorlevel = 2 goto end @if errorlevel = 1 goto end @if errorlevel = 0 goto success :success @Echo Port %1 is listening goto end :end NOTE: When you use the -q switch with the -l (log file) switch, Portqry.exe overwrites an existing log file with the same name, and does not prompt you for permission to do so. To Obtain Portqry.exePortqry.exe is available for download from the Microsoft Download Center. To download Portqry.exe, visit the following Microsoft Web site:http://www.microsoft.com/downloads/details.aspx?familyid=89811747-C74B-4638-A2D5-AC828BDC6983&displaylang=en
(http://www.microsoft.com/downloads/details.aspx?familyid=89811747-C74B-4638-A2D5-AC828BDC6983&displaylang=en)
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591
(http://support.microsoft.com/kb/119591/EN-US/
)
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
| Article Translations
|
Back to the top
