Windows – abort telnet while it is still trying to connect

telnetwindows

At times I find myself telnetting from Windows XP to another server and that I state a wrong port number such as

c:\> telnet xxxxx.yy pp

After hitting Enter, I realize that I entered the wrong port number and would like to abort the telnet process with a ctrl-c, however, telnet doesn't seem to respond even to ctrl-c. So, I have to wait a few seconds until telnet returns with a

Connecting to xxxxx.yy... 
Could not open connection to the host, on port pp: Connect failed

It's rather annoying to wait for the error message, especially when I already know it will eventually come.

So, is there a way to immediately stop the telnet process?

Best Answer

Edit: Of course, it's never that simple. As you've observed, Microsoft's telnet doesn't respond to ^] while waiting for a connection.

If you don't want to wait around, you only have two options:

  • Kill the telnet process (from another command shell or the task manager), or

  • Use another telnet client. PuTTY is a good choice, since it will launch as a separate window; even if you get the port wrong and the PuTTY window freezes, your command shell will be available to launch another instance with the correct port number.


Use the escape character (defaults to Ctrl+]). This brings up a telnet prompt at which you can close or quit the connection.

> telnet

Welcome to Microsoft Telnet Client

Escape Character is 'CTRL+]'

Microsoft Telnet> 

You can change this to nearly anything you like on your commandline by using the -e flag:

C:\>telnet /?

telnet [-a][-e escape char][-f log file][-l user][-t term][host [port]]
[...]
 -e      Escape character to enter telnet client prompt.
[...]

C:\>telnet -e '

Welcome to Microsoft Telnet Client

Escape Character is '''

Microsoft Telnet>
Related Question