0

This is my batch file:

ansicon -p

[0;30;4;40mThis is a sentence.[0;1;31;40mThis is a sentence too.
  
pause

With @echo off in the batch file I'm only seeing:

's not recognized as an internal or external command, operable program or batch file.

With @echo on I'm seeing:

C:\Users\Admin\Downloads\Aranesp_injection_reminder\ANSICON>ansicon -p

C:\Users\Admin\Downloads\Aranesp_injection_reminder\ANSICON>This is a sentence.This is a sentence too.

's not recognized as an internal or external command, operable program or batch file.

What am I doing wrong?

Obs.: Using 0x1b for the ESC character.

Io-oI
  • 7,588
  • 3
  • 12
  • 41
  • 1
    To show something on the screen, you have to use echo command. Otherwise it is trying to execute your sentence. – Rohit Gupta Jul 29 '23 at 13:06

1 Answers1

0

Using 0x1b for the ESC character.

  • Use ESC saved in variable

  • In your batch file:
@echo off

color 0a

for /f skip^=4 %%b in ('"echo;prompt;$E|cmd"')do set "_esc=%%b"

echo/%_esc%[0;30;4;40mThis is a sentence. %_esc%[0;1;31;40mThis is a sentence too

timeout 3 >nul & color f0

  • In your command-line:
for /f skip^=4 %b in ('"echo;prompt;$E|cmd"')do @echo\ %b[0;30;4;40mThis is a sentence.%b[0;1;31;40m. This is a sentence too & timeout 3 >nul & color f0

ANSI Escape Sequences

Use ANSI colors in the terminal

Tetris.BAT by @Aacini

Flappy_Bird.bat

Pacman_kinda.bat

Library.bat Revision 4.1.0

Search for "Bat Games" on DosTips.com

Io-oI
  • 7,588
  • 3
  • 12
  • 41
  • Is ANSICON.EXE not needed in Windows 10? I would still like to know how to use the program. Even when I use it in the following way - I get allot of these messages i.e 's not recognized as an internal or external command, operable program or batch file. Viz: ansicon.exe -p C:\Users\Admin\TEST\colors.bat - where color.bat contains entries like this: [0;30;40m [0m [0;1;30;40m [0m [0;30;4;40m [0m [0;1;30;4;40m [0m – Einar Flaathe Jul 30 '23 at 08:08
  • No, ansicon.exe is not required. – Io-oI Jul 30 '23 at 13:56
  • OKAY thank you for that! i haven't found any versatile examples using ASCICON - only how to install and de-install the program. Is there a site that shows allot of examples using ANSICON? Are using ANSI escapes sequences easier to use with ASCICON or not? – Einar Flaathe Jul 30 '23 at 16:46
  • Try looking specifically for ***using ansi code*** and not how to use a *program that uses ansi code*. You can see an example [without using ansicon.exe](https://superuser.com/questions/1718940/how-to-clear-message-sent-by-echo-command/1719889#1719889) – Io-oI Jul 30 '23 at 17:27
  • Do I need to have VirtualTerminalLevel as a DWORD set to 0x1 in Computer\HKEY_CURRENT_USER\Console to use ANSI escapes sequences?? I will not be using ANSICON.exe anymore. – Einar Flaathe Aug 01 '23 at 09:44
  • No need, my windows doesn't even have that entry in my registry. – Io-oI Aug 01 '23 at 13:52