Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
For a simple ASCII command, configure the port with mode and redirect the command to the COM device:
@echo off
mode COM3:9600,n,8,1
echo STATUS>COM3
Replace COM3, the serial settings, command text, and line ending with the values specified by your device manual. This works for basic text protocols, but native batch becomes unreliable when you need exact bytes, binary packets, response parsing, timeouts, retries, or precise flow-control handling.
What a “serial COM port command” actually is
mode and echo are Windows commands. STATUS, ATZ, VER?, and *IDN? are examples of commands understood by the attached device—not by Windows itself.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchBefore writing the batch file, obtain these details from the device documentation:
#1 Best Overall
- !!Please NOTE: this is MALE RS232 to DB9 SERIAL CABLE ,Not VGA!!!It is 9 pin, NOT 15 pin!! Look carefully of the Pin is match with your device. Before ordering , please confirm the interface gender is waht you need. After receiving ,please read user manual /instruction at first and download the Driver at first from FT232 Official website or Cisco website . Customer service always online.
- Wide range of applications: USB to RS232 DB9 male serial adapter can work with your Windows (10 / 8.1 / 8 / 7 / Vista / XP), MAC or Linux system and other platforms. USB adapter is designed to connect to serial devices, such as serial modem with DB9, ISDN terminal adapter, digital camera, label writer, palm computer, barcode scanner, PDA, cash register, CNC, PLC controller, tax printer, POS, bar code scanner, label printer, etc
- High quality: ftdi usb serial,the latest ftdi chip set ensures more reliable and faster operation. USB 2.0 to RS232 male DB9 console cable will support 1Mbps date transfer rate.
- Most convenient: rs232 to usb simple installation, plug and play, COM port creation, baud rate can be changed to the required settings. USB power supply - no external power supply required.
- Exquisite design: usb-to-serial,Gold Plated USB RS232 connector and PVC cable ensure high performance and extra durability. Powered by USB port, this USB to DB9 series RS232 adapter cable is designed to fit easily into your handbag.
- Baud rate
- Data bits
- Parity
- Stop bits
- Hardware or software flow control
- Required terminator: carriage return (CR), line feed (LF), CRLF, or none
- Any startup or inter-command delay
- Whether the device echoes commands
- Expected response and timeout
Do not assume every COM device accepts readable text. Instruments, PLCs, controllers, and embedded devices may require binary frames, checksums, escape bytes, acknowledgements, or fixed-length packets.
Before you start: identify and free the port
- Open Device Manager.
- Expand Ports (COM & LPT).
- Find the device or USB-to-serial adapter, such as
USB Serial Port (COM3). - Close PuTTY, Tera Term, Arduino IDE serial monitors, vendor tools, and other programs that may have the port open.
Only one application can normally open a COM port for exclusive serial communication. You can display the current status with:
mode COM3
For a reusable script, keep the port and settings in variables:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →@echo off
set "PORT=COM3"
set "BAUD=9600"
mode %PORT%: baud=%BAUD% parity=n data=8 stop=1
echo STATUS>%PORT%
Batch has no convenient, dependable built-in port-discovery workflow. PowerShell can enumerate available ports through System.IO.Ports.SerialPort.GetPortNames(). See Microsoft’s SerialPort documentation.
Configure the COM port with mode
The general syntax is:
mode COM<m>: baud=<rate> parity=<p> data=<bits> stop=<bits>
A common, but not universal, configuration is 9600 baud, 8 data bits, no parity, and one stop bit:
mode COM3:9600,n,8,1
| Setting | Meaning | Examples |
|---|---|---|
baud |
Transmission speed | 9600, 115200 |
parity |
Error-checking mode | n none, e even, o odd |
data |
Data bits per character | 7 or 8 |
stop |
Stop bits | 1 or 2 |
mode also supports serial handshaking and signaling options, including XON/XOFF, DSR/DTR, and CTS/RTS. Use the syntax documented for your Windows version and match the device manual rather than relying on 9600 8-N-1. Microsoft’s mode reference lists the available parameters.
Rank #2
- [ USB to RS-232 Serial Adapter ] : 5ft Cable Length - Easily connect legacy DB-9 serial devices to modern USB-equipped computers. Uses include industrial, lab, and point-of-sale applications.
- [ Easy Testing ] : Built-in signal tester features full LED indicators with dual-color display for quick and easy testing of RS-232 host-to-device connections.
- [ Wide Compatibility ] : Built with an FTDI Chipset. Works seamlessly with Windows 7, 8, 10, 11, Linux, and macOS 10.X, making it a highly versatile solution across platforms.
- [ Why Gearmo? ] : Your trusted partner based in the USA, providing advanced engineering, highly reliable and superior built products to handle the most demanding industries for over 10 years.
- [ Engineering Support ] : Need specs? Contact us for CAD files, mechanical drawings, or datasheets to support your integration or project needs.
Method 1: send a simple text command with echo
For a device that accepts one plain-text command and the line ending produced by the command path, use:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
@echo off
mode COM3:9600,n,8,1
echo ATZ>COM3
You can send several lines as one redirected block:
@echo off
mode COM3:9600,n,8,1
(
echo LOGIN
echo STATUS
echo EXIT
)>COM3
This is convenient, but echo is text-oriented and appends the command interpreter’s line ending. Do not treat that as a protocol guarantee. A device requiring CR only may reject a command when the transmitted data includes LF as well, while another device may require LF or CRLF.
Batch also has special-character parsing rules. Characters such as &, |, <, >, ^, and parentheses can be interpreted by cmd.exe instead of being sent literally. The Microsoft cmd reference explains command-interpreter parsing.
Method 2: send exact bytes with copy /b
Use a prepared file when the payload must contain an exact terminator, non-printable bytes, a checksum, or a binary packet:
@echo off
mode COM3:9600,n,8,1
copy /b command.bin COM3
The file might contain:
ATZfollowed by byte0x0Dfor CR-only terminationSTATUSfollowed by byte0x0Afor LF-only termination- A binary header, length field, payload, checksum, and terminator
copy /b is appropriate for binary-oriented transmission, but it can only send the bytes actually present in command.bin. A text editor may add a UTF-8 BOM, convert newlines to CRLF, change encoding, or append an unintended final newline.
Rank #3
- Serial adapter allows a serial device to be connected to a USB computer
- Plug and play convenience:DB9 serial port is seen as a COM port by your computer, and is available for use by any program that accesses COM ports
- No need for an external power adapter:draws power directly from your computer via the USB connection
- DB9 serial port supports data transfer rates up to 230 Kbps:twice the speed of a standard built in serial port
- LED shows adapter status and data activity at a glance
For a repeatable CR-terminated ASCII file, generate it explicitly:
powershell -NoProfile -Command ^
"[IO.File]::WriteAllBytes('command.bin',[Text.Encoding]::ASCII.GetBytes('ATZ' + [char]13))"
copy /b command.bin COM3
Keep payload generation separate from transmission and document the intended byte sequence. For checksums or dynamic binary packets, PowerShell or a dedicated program is usually safer than hand-editing a file.
COM10 and higher-numbered ports
Legacy command contexts may handle high-numbered ports differently. Some redirection and copy operations may require the Windows device path:
echo STATUS>. COM10
copy /b command.bin . COM10
In publication HTML, the literal Windows form is:
echo STATUS>. COM10
copy /b command.bin . COM10
More precisely, the intended device-path spelling is \.COM10 at the Windows command line. Test the exact command you use; do not assume every legacy command treats COM10 identically. PowerShell’s SerialPort API avoids this particular naming issue:
$port = [System.IO.Ports.SerialPort]::new(
'COM10', 9600, 'None', 8, 'One'
)
$port.Open()
$port.Write("STATUS`r")
$port.Close()
Method 3: call PowerShell from the batch file
Use PowerShell when the workflow needs explicit line endings, response reads, timeouts, exceptions, or guaranteed cleanup. Save this as send-serial.ps1:
param(
[string]$PortName = 'COM3',
[int]$BaudRate = 9600,
[string]$Command = 'STATUS',
[string]$Terminator = "`r",
[int]$WaitMilliseconds = 500
)
$port = [System.IO.Ports.SerialPort]::new(
$PortName,
$BaudRate,
[System.IO.Ports.Parity]::None,
8,
[System.IO.Ports.StopBits]::One
)
$port.Handshake = [System.IO.Ports.Handshake]::None
$port.ReadTimeout = 1000
$port.WriteTimeout = 1000
$port.NewLine = $Terminator
try {
$port.Open()
Start-Sleep -Milliseconds 200
$port.Write($Command + $Terminator)
Start-Sleep -Milliseconds $WaitMilliseconds
if ($port.BytesToRead -gt 0) {
$response = $port.ReadExisting()
$response
}
}
finally {
if ($port.IsOpen) {
$port.Close()
}
$port.Dispose()
}
Call it from send.bat:
@echo off
powershell.exe -NoProfile -File "%~dp0send-serial.ps1" ^
-PortName COM3 ^
-BaudRate 9600 ^
-Command STATUS ^
-Terminator "`r"
The Terminator value above is a carriage return. Use "`n" for LF or "`r`n" for CRLF when required. Prefer a separate .ps1 file over an inline command because quoting, error handling, settings, and reuse are clearer.
Rank #4
- √USB to 9-pin serial cable Product features: easy installation, no external power supply, and physical drive required
- √Applicable scope: This product can easily realize the conversion between the USB interface of the computer and the universal serial port, providing a fast channel for the computer without a serial port, and using this product is equivalent to turning the traditional serial port device into a plug-and-play USB device.
- √ Supports various models of MCU, MCU STC download, LED screen control card, MODEM, and ISDN terminal adapter communication is suitable for computers or notebooks with USB ports.
- √Application platform: Support USB1.0/1.1 specification, compatible with USB2.0 specification, support full-speed transfer mode 12MBPS, support Win98, 98SE, Me, 2000, XP, Mac OS8.6, vista, win7-32, 64-bit.
- √Installation Instructions: 1. Run the driver CH340.EXE file to install 2. Connect the USB serial cable to the USB interface of the computer, and automatically install the driver 3. After the installation is successful, the COM port appears in the device manager
For a quick one-line invocation:
powershell.exe -NoProfile -Command ^
"$p=[IO.Ports.SerialPort]::new('COM3',9600,'None',8,'One'); ^
$p.ReadTimeout=1000; ^
$p.WriteTimeout=1000; ^
$p.Open(); ^
$p.Write('STATUS' + [char]13); ^
Start-Sleep -Milliseconds 500; ^
if($p.BytesToRead -gt 0){$p.ReadExisting()}; ^
$p.Close()"
The .NET SerialPort API supports port opening, text and byte writes, reads, encoding, timeouts, and handshaking. The available PowerShell and .NET versions depend on the Windows installation and PowerShell edition.
Why explicit terminators matter
WriteLine() appends the value of SerialPort.NewLine. Microsoft documents the default NewLine value as LF, not automatically CRLF. Set it explicitly or write the terminator yourself:
$port.NewLine = "`r"
$port.WriteLine('STATUS')
# Equivalent explicit write:
$port.Write('STATUS' + [char]13)
See Microsoft’s documentation for WriteLine() and NewLine.
Reading and saving the response
A quick diagnostic is:
copy COM3 CON
However, a COM port is a stream, not a finite file. This command can wait indefinitely and provides no protocol-level timeout or response validation.
Choose the read method based on the protocol:
- Immediate available data:
$port.ReadExisting(). It returns currently available data and does not itself impose a timeout. - Line-oriented response:
$port.ReadLine(). It waits for the configured newline and can throw a timeout exception whenReadTimeoutis set. - Fixed-length binary response: use
Read()into a byte buffer and continue until the required length arrives. - Terminator-based response: use
ReadTo()with the protocol’s terminator. - Unknown-length response: read until a deadline, terminator, or protocol-specific acknowledgement.
For a text response, capture and log it from PowerShell:
$response = $port.ReadExisting()
$response | Out-File -FilePath '.serial-response.log' -Encoding utf8
For binary data, do not decode it as ordinary text. Read bytes and save bytes so encoding cannot corrupt the response. Microsoft’s ReadExisting() documentation also warns that mixing text and binary reads requires clearly defined protocol boundaries.
Best Value
- Gold Plated USB 2.0 to RS232 Female DB9 Serial Cable connects serial DB9 (9 PIN) devices such as modems to standard computer USB ports, supporting up to 1Mbps data transfer rate. [ IMPORTANT NOTE ]: This USB to RS232 adapter features a female RS232 connector, NOT male — please confirm your device’s serial port type before purchase
- Adopted with latest Prolific PL2303 chipset, this USB to RS232 adapter supports Windows 11/10/8.1/8/7, Linux and Mac OS. Windows 11/10/8.1/8/7 is plug-and-play and will be automatically identified as COM port. Windows built-in drivers match most USB-to-serial chips; it will automatically download and install the matched driver under network environment. For offline Windows, Mac OS and most Linux systems, please download and install the official driver from CableCreation official website. Ubuntu Linux supports plug and play without driver installation
- Widely compatible with modems, ISDN terminal adapters, digital cameras, label writers, palm PCs, PDAs, cash registers, CNC, PLC controllers, tax printers, POS machines, barcode scanners, and other devices with standard DB9 serial ports. Please be noted this USB to RS232 female DB9 serial converter cable is NOT compatible with cutting plotter and SCM equipment. Kindly confirm your device interface and model before placing an order
- Features tinned copper conductor and triple shielding to ensure stable and high-quality data transmission. USB bus-powered design requires no external power adapter. If your computer cannot recognize the cable normally, please match it with a null modem adapter for normal use
- CableCreation provides 24-month warranty and lifetime professional customer service. This 6.6ft USB 2.0 to RS232 Female DB9 serial converter cable follows standard pin definition, suitable for the device requiring female RS232 interface. If you encounter any problems of driver installation or device compatibility, please contact our customer service at any time, and we will assist you within 24 hours
Timing, readiness, and flow control
Opening a port can change control lines such as DTR, and some devices reset or need boot time when that happens. Other devices need a pause before accepting a command or between commands:
$port.Open()
Start-Sleep -Milliseconds 200
$port.Write("STATUS`r")
Start-Sleep -Milliseconds 500
These delays are examples, not universal requirements. Use the device’s documented timing and acknowledgement rules.
| Mode | PowerShell setting | Typical implication |
|---|---|---|
| No flow control | Handshake=None |
Data is sent without XON/XOFF or hardware handshaking. |
| Software flow control | Handshake=XOnXOff |
The device uses XON/XOFF characters to regulate transmission. |
| Hardware flow control | Handshake=RequestToSend or another documented mode |
RTS/CTS or related control signals must be wired and configured correctly. |
A script using Handshake=None may appear to write successfully but fail with a device requiring hardware handshaking. Conversely, enabling hardware flow control on a cable that lacks the required signals can prevent transmission. DTR and RTS states may also need explicit control.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsBatch error handling: what success does and does not mean
At minimum, check whether Windows accepted the configuration and write operation:
@echo off
set "PORT=COM3"
mode %PORT%:9600,n,8,1
if errorlevel 1 (
echo Could not configure %PORT%.
exit /b 1
)
echo STATUS>%PORT%
if errorlevel 1 (
echo Failed to send command.
exit /b 1
)
A successful redirection generally means Windows accepted the write operation. It does not prove that the cable is wired correctly, that the device understood the framing, or that the device acted on the command. Application-level success requires checking the response or acknowledgement.
Troubleshooting guide
| Symptom | Likely causes and checks |
|---|---|
| Device receives nothing | Wrong COM port, missing driver, incorrect cable or null-modem wiring, wrong framing, flow-control mismatch, DTR/RTS state, port lock, or device not in command mode. |
| Device receives text but does not act | Wrong CR/LF/CRLF terminator, missing checksum, wrong command syntax or case, extra newline, missing delay, authentication requirement, or device still booting. |
| Works in PuTTY but not in batch | Compare baud, parity, data bits, stop bits, flow control, local echo, CR/LF translation, transmit delays, and DTR/RTS behavior. A terminal may transform characters or control signals. |
| Script hangs | A stream is being read like a finite file, the script is waiting for a newline never sent by the device, no read timeout is set, flow control is waiting for a signal, or the device stopped responding. |
| Response is garbled | Check framing, encoding, non-printable control bytes, and whether a binary response is being decoded as text. |
| Access denied or port unavailable | Close terminal monitors and vendor tools, stop background serial services, and verify the port name in Device Manager. |
| COM10 fails | Try the device-path form \.COM10 for the specific command or use PowerShell’s SerialPort API. |
| Device resets on open | Investigate DTR/RTS behavior and add the device’s required startup delay before sending. |
When batch is not the right tool
Use native batch for a one-shot ASCII write or a small, non-interactive sequence. Use copy /b when the payload is already prepared and exact bytes matter.
Use PowerShell and SerialPort when you need explicit settings, terminators, byte handling, bounded reads, exceptions, response validation, logging, retries, or cleanup.
Recommended Free Tools
A terminal utility can be better for interactive diagnosis, session logging, or macro playback. Tera Term documents command-line options such as /C= for selecting a serial port, /WAITCOM, and /M= for starting a macro. PuTTY’s documentation covers its terminal utilities and workflows. Exact options and behavior depend on the selected program and version.
For binary protocols with checksums, retries, multiple devices, long-running monitoring, or strict acknowledgement rules, a dedicated PowerShell, Python, or compiled application is usually easier to test and maintain than a growing batch file.
Quick Recap
Recommended method by requirement
| Requirement | Best starting point |
|---|---|
| One simple ASCII command | mode plus redirected echo |
| Several plain-text commands | Redirected echo block, with documented timing limitations |
| CR-only, LF-only, or binary payload | Prepared file and copy /b |
| Response capture and timeouts | PowerShell SerialPort |
| Interactive testing or macro sessions | Tera Term or PuTTY, depending on the required workflow |
| Checksums, retries, structured parsing, or unattended production control | PowerShell or a dedicated serial application |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

