Automatically Connect & Disconnect Tera Term USB COM Ports

As an embedded software engineer, I frequently utilize serial connections to embedded devices, often using virtual USB COM ports. This resulted in a pain point that I set out to resolve by good ol’ hacking.

Oftentimes, I am connected to a device’s USB COM port with Tera Term and then need to reset the device. When I do that, the virtual USB COM port is also reset. Therefore, each time I reset a device, I have to manually disconnect the Tera Term COM port, reset the device, wait for the USB COM port to enumerate, and then manually reconnect with Tera Term. This is a relatively small thing, I know, yet when you do this many times a day, it really adds up.

To solve this problem, I wrote an AutoHotkey script for Windows that automatically disconnects Tera Term if the connected to port goes away and then automatically reconnects Tera Term if that port comes back.

To use it, you just need to install AutoHotkey and download this script. First open the script in a text editor and set the COM ports that you want to monitor, and then double-click the script to start it (placing a shortcut to it in your Startup folder will cause it to auto load on boot).

P.S. AutoHotkey is an amazing program for Windows that you can use to create custom keyboard shortcuts, text abbreviations, and even remap your keyboard to be more user-friendly (future blog post!).

7 comments so far - chime in below!

  1. I just wanted to say thanks for sharing this. It’s working well for me.

  2. Hello,

    Interested in checking out your script for TeraTerm, however the link seems to the be broken. I found your new Github at flybayer but don’t see the script. Is it still available somewhere? Looking forward to trying it! Thanks.

  3. I spoke too soon. Found the script and it appears to work great! Thanks!!

  4. I am using USB Barcode Scanner with virtual USB COM ports 3, how should I edit the script to let the script can run after put in startup therefore I do not need to unplug my USB Barcode Scanner everyday I turn on my PC.
    Thank you for anyone who can help me.

  5. Hi Brandon,

    Thanks for sharing this useful work.
    Do you have a script to send a command through com port to connected device using Teraterm?

    /Samy

  6. Hi Brandon,

    Do you have a script to send a command through com port to connected device using Teraterm?…..any idea?

    /Samy

Leave a Reply to Samy B. Cancel reply

Your email address will not be published. Required fields are marked *