Skip to main content

How to Display a Blinking Text Effect in Batch Script

Back in the early days of computing, the "Blink" effect was a standard way to signal critical errors or hardware failures. While modern UI design often discourages blinking because it can be distracting or inaccessible to some users, it remains a powerful tool for specialized Batch scripts, such as emergency alarm monitors or "Self-Destruct" sequence simulations, where you need to grab the user's attention immediately.

In this guide, we will demonstrate how to create a blinking text effect using modern ANSI Escape Codes and a manual fallback approach.

Modern Windows terminals support the SGR (Select Graphic Rendition) code for blinking.

  • Blink (Slow): ESC[5m
  • Reset: ESC[0m
Terminal compatibility

The ANSI blink code (ESC[5m) has very limited support on Windows. Windows Terminal does not currently render blinking text, the text appears static with no visual effect. The legacy ConHost (cmd.exe) also does not support it. If you need a guaranteed blinking effect on Windows, use the manual approach in Method 2 below.

This approach uses the standard ANSI blink escape sequence. While it may not produce a visible blink on most Windows terminals, it is the standards-compliant method and will work in terminals that support it (such as some third-party terminal emulators or remote SSH sessions to Linux systems).

Implementation Script

@echo off
setlocal enabledelayedexpansion

:: Capture the Escape character (ASCII 27)
for /F "delims=" %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"

if not defined ESC (
echo [ERROR] Could not generate ANSI escape character.
pause
exit /b 1
)

:: Define formatting variables
set "BLINK=!ESC![5m"
set "BOLD=!ESC![1m"
set "RED=!ESC![91m"
set "RESET=!ESC![0m"

echo.
echo Standard text output.
echo.
echo !BOLD!!RED!!BLINK! WARNING: CRITICAL OVERHEAT DETECTED !RESET!
echo.
echo Monitoring continued...

endlocal
pause

Since the ANSI ESC[5m code is not rendered by most Windows terminals, the most reliable way to produce a visible blink effect is to use a loop that alternates between showing and hiding the text. This version uses ANSI cursor positioning to overwrite text in place, avoiding the full-screen flicker caused by cls.

@echo off
setlocal enabledelayedexpansion

for /F "delims=" %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"

if not defined ESC (
echo [ERROR] Could not generate ANSI escape character.
pause
exit /b 1
)

set "BOLD=!ESC![1m"
set "RED=!ESC![91m"
set "RESET=!ESC![0m"

set "msg=*** CRITICAL ALERT: SYSTEM OVERHEAT ***"

:: Blank string must be at least as long as the message to fully erase it
set "blank= "

cls
echo Press Ctrl+C to stop.
echo.

:: Save the line number where the message will blink
:: We use line 3 (after the header and blank line)
set "msgRow=3"

:blink_loop
:: Show the message
<nul set /p "=!ESC![!msgRow!;1H!BOLD!!RED!!msg!!RESET!"

:: Wait ~500ms (192.0.2.1 is a non-routable RFC 5737 address, forcing a timeout)
ping -n 1 -w 500 192.0.2.1 >nul

:: Hide the message by overwriting with spaces
<nul set /p "=!ESC![!msgRow!;1H!blank:~0,40!"

:: Wait ~500ms
ping -n 1 -w 500 192.0.2.1 >nul

goto blink_loop

If you are on an older version of Windows (like Windows 7) where ANSI codes are not available, you can create a manual blink using cls. This causes full-screen flicker but works on all Windows versions.

@echo off
set "msg=CONNECTING TO SERVER..."

echo Press Ctrl+C to stop.

:blink_loop
:: Show the message
cls
echo %msg%
ping -n 1 -w 500 192.0.2.1 >nul

:: Hide the message
cls
echo.
ping -n 1 -w 500 192.0.2.1 >nul

goto blink_loop
Why ping for delays

Batch doesn't have a built-in sub-second delay command. The timeout command only supports whole seconds. Using ping -n 1 -w 500 192.0.2.1 creates an approximate 500ms delay. We use 192.0.2.1, a non-routable address from the RFC 5737 TEST-NET-1 range, because it guarantees the ping will time out after the specified -w milliseconds. Using 127.0.0.1 would not work because localhost always responds instantly, making the timeout meaningless.

Use Blink When:

  • Displaying a catastrophic failure (e.g., "DATABASE WIPED").
  • In "Kiosk" mode scripts where a terminal is used as a status board and needs to draw attention from across a room.
  • For fun "Hacker" or retro-themed scripts.

Avoid Blink When:

  • Displaying standard information (it makes it hard to read).
  • In tools used by people with photosensitive epilepsy or other visual sensitivities.
  • For non-critical warnings where a simple red bold color would suffice.

Summary

The blinking text effect is the ultimate "HEY, LOOK HERE" signal in a text-based environment. Since the ANSI ESC[5m blink code is not supported by most Windows terminals, the most reliable approach on Windows is a manual show/hide loop using ANSI cursor positioning to avoid screen flicker. For legacy systems without ANSI support, a cls-based loop provides a basic fallback. Use blinking sparingly, and it remains one of the most effective tools in a Batch programmer's visual arsenal.