@echo off rem Copyright (c) 2009 Igor Nikolaev if "%1" == "" goto portNotSpecified netstat -an | findstr /R "^[^a-zA-Z]*[a-zA-Z]*[^:]*:%1[^0-9][^a-zA-Z]*LISTENING$" if %errorlevel% == 0 goto portIsUsed goto portIsNotUsed :portNotSpecified echo Usage: checkport port goto exit :portIsUsed echo Port %1 is used goto exit :portIsNotUsed echo Port %1 is not used goto exit :exit exit %errorlevel%