How to Display Multi-Line ASCII Logos at Script Start in Batch Script
First impressions matter. When you distribute a Batch tool to your team or clients, a high-quality ASCII Logo provides a professional "Branding" moment. It makes your script feel like a dedicated application rather than just a collection of console commands. It establishes trust and identifies the tool immediately upon startup.
In this guide, we will demonstrate the standard way to display multi-line ASCII art without running into "Escape Character" errors.
The Challenge: Special Characters
ASCII art often uses characters like <, >, |, &, (, ), and %. In Batch, these are Reserved Characters used for redirection, piping, grouping, and variable expansion. If you try to echo them without proper escaping, the script will crash or produce unexpected output.
| Character | Batch Meaning | Escape Syntax |
|---|---|---|
< > | Input/Output redirection | ^< ^> |
| ` | ` | Pipe operator |
& | Command separator | ^& |
( ) | Code block grouping | ^( ^) |
% | Variable expansion | %% |
Method 1: The "Caret" Escape (Standard)
The most common way to handle ASCII art is to put a caret (^) before every special character. The % character is the exception, it is escaped by doubling it (%%).
Implementation
@echo off
cls
echo.
echo ^+--------------------^+
echo ^| WELCOME TO MY APP ^|
echo ^| Version 1.0 ^|
echo ^| Status: Running ^|
echo ^+--------------------^+
echo.
pause
When to use this method: Caret escaping works well for simple logos that use only a few special characters. For complex artwork with many pipes, angle brackets, and ampersands, the number of carets makes the source code very hard to read and maintain. In those cases, Method 2 (external file) is strongly recommended.
Method 2: The "Type" File (Cleanest)
If your ASCII art is complex, escaping every single character is tedious and error-prone. A much better practice is to save the logo in a separate text file (e.g., logo.txt) and display it with the type command. Text files have no special character restrictions.
Implementation
- Create
logo.txtwith your ASCII art (no escaping needed). - In your
.batfile:
@echo off
cls
:: %~dp0 resolves to the directory where the batch file is located,
:: ensuring the logo file is found even when the script is run
:: from a different working directory (e.g., via a shortcut)
if exist "%~dp0logo.txt" (
type "%~dp0logo.txt"
) else (
echo ==========================================
echo [ LOGO FILE MISSING ]
echo ==========================================
)
echo.
echo System Initialized...
echo.
pause
Advantages of the external file approach:
- No escaping required: The
typecommand outputs the file contents exactly as written. Characters like|,<,>, and&display correctly without any caret escaping. - Easy to update: You can change the logo by editing the text file without touching the script logic.
- Separation of concerns: The visual design is separated from the script logic, making both easier to maintain.
Method 3: Using ANSI for Colored Logos
On modern Windows (10/11), you can combine ASCII art with ANSI color codes to create a visually striking branded header.
@echo off
setlocal DisableDelayedExpansion
:: 1. Setup ANSI Colors
for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
if not defined ESC (
echo [WARNING] ANSI not available. Displaying logo without color.
set "C_LOGO="
set "C_RESET="
) else (
set "C_LOGO=%ESC%[94m"
set "C_RESET=%ESC%[0m"
)
cls
:: 2. Print colored ASCII logo
echo %C_LOGO%
echo ______ ______ ______
echo / ____ \ / ____ \ / ____ \
echo / / __ \ / / __ \ / / __ \ \
echo \ \ \/ / \ \ \/ / \ \ \/ / /
echo \ \__/ / \ \__/ / \ \__/ /
echo \____/ \____/ \____/
echo %C_RESET%
echo.
echo SECURE PORTAL v2.0
echo.
pause
endlocal
Combining Methods 2 and 3: For the best of both worlds, you can store the ASCII art in an external file and add ANSI color codes when displaying it:
if defined ESC <nul set /p "=!C_LOGO!"
if exist "%~dp0logo.txt" type "%~dp0logo.txt"
if defined ESC echo !C_RESET!
This keeps the logo file free of ANSI codes (making it editable in any text editor) while still displaying it in color.
Creating Your Own Logo
You don't have to draw ASCII art by hand. You can use free online ASCII Art Generators such as:
- FIGlet / patorjk.com generates text-based logos in dozens of font styles.
- Recommended Styles: Slant, Banner, Standard, or Block.
- Width Tip: Keep your logo width under 75 characters so it doesn't wrap on standard 80-column terminal windows.
Best Practices
- Clear the Screen: Always use
clsbefore displaying a logo so that the branding is the first thing the user sees without clutter from previous commands. - Use Relative Paths: Use
%~dp0logo.txtto locate the logo file relative to the script's own directory. This ensures the file is found even when the script is run from a different working directory or via a desktop shortcut. - Include Version Information: Display the version number and tool name immediately below the logo for clear identification.
- Test Special Characters: If using Method 1 (inline art), test every line of your logo individually. A single unescaped
|or&can cause the script to fail silently or execute unintended commands. - Consider Width: Preview your logo at 80 columns wide (the default
cmd.exewidth). Logos wider than the terminal will wrap and look broken.
Conclusion
Displaying a multi-line ASCII logo transforms a plain Batch script into a branded product. Whether you use the "Caret" escape method for simple artwork or the "Type" file method for complex designs, you provide your users with a clear and professional entry point into your software. This layer of visual polish is a hallmark of high-quality systems administration and development.