Expanding on Witto's comments, and assuming your looking to test just accessibility versus whether the telnet ports are specificically open or not, this code works. Just change the $WKSTA variable to test good and bad hostnames.

Code:

break on

$wksta = @WKSTA

shell '%comspec% /c ping -n 2 $wksta | find /i "TTL=" >NUL 2>NUL'

if @ERROR = 0
?"$wksta is accessible!"
else
?"$wksta is not accessible!"
endif

exit 0



Or - are you looking to test specifically whether telnet is available ?

-Shawn