ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#1 Post by Jer » 13 Apr 2018 12:00

My 2 Windows 7 PCs have ANSI.SYS and I added DEVICE = C:\WINDOWS\SYSTEM32\ANSI.SYS
to the config.sys file for both, re-booted, with no success in displaying color in the CMD console
window.
I suppose it is common knowledge that Windows 7 does not support ansi.sys, but my
question (probably unanserable) is, why is the ansi.sys file there? What genius
decided to include a non-supported file in the Windows 7 system32 folder? :roll:

What do you recommend? I am working with escape sequences as a color "add-on"
for my pure batch borders & boxes project. I want to see the colors with Windows 7 as
I do on the Windows 10 PC.
Thanks.

Code: Select all

@echo off
setlocal

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

set "reset=%ESC%[0m"
set "Red=%ESC%[31m"
set "Green=%ESC%[32m"

echo %Red% red %Green% green %reset%
exit /b
Windows 7 result ("e" represents a left-pointing arrow on the display):
e[31m red e[32m green e[0m

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#2 Post by aGerman » 13 Apr 2018 12:41

I think the file is still there for historical or downward-compatibility reasons. I'm afraid you don't have any chance to use it on Win7. Also on Win10 it works only with the new console window. If you use the so called "Legacy Console" (wich is the old console window used before Win10) it also won't work.

Steffen

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#3 Post by Ed Dyreen » 14 Apr 2018 16:46

Windows NT,2K and later don't use autoexec.bat nor config.sys but autoexec.nt and config.nt. If you add the following line to the config.nt file it works for command.com but not cmd.exe however I remember to once have read a 3th party ansi.sys exist that claimed to work on cmd.exe.

Code: Select all

DEVICE=C:\WINDOWS\SYSTEM32\ANSI.SYS

elzooilogico
Posts: 128
Joined: 23 May 2016 15:39
Location: Spain

Re: ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#4 Post by elzooilogico » 15 Apr 2018 04:58

you may try ansicon developed by Jason Hood

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#5 Post by Jer » 22 Apr 2018 21:39

Thank you all for the comments and suggestions.
I installed ansicon on my Windows 7 laptop, and it allows me
to get any of the 256 colors from batch scripts that assign ansi codes.
This is a relief knowing that a "future" shared batch script would
include a batch-only coloring add-on that would be unappreciated by
those who only had a Windows 7 O/S.

To make ansicon work, per instructions, I copied the x86 folder
to a folder in the path, and typed on the command-line ansicon -i

It continues to work after several boot-ups.

This is a step in a bigger challenge, to be able to take an existing file
of bordered information or bordered other ascii characters, and colorize
(with different selected colors) borders, specific lines and specific columns.
Editing a line with text of one color and multiple vertical columns of
another color involves multiple edits of the same line, and the escape codes
added to a text string prevent further edits after the initial edit causes the
line to grow with the added codes. With time and persistence and
ideas :idea: in the middle of the night, maybe this can be done.
Jerry

pjanov
Posts: 1
Joined: 24 Apr 2018 00:18

Re: ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#6 Post by pjanov » 24 Apr 2018 00:20

Windows NT,2K and later don't use autoexec.bat nor config.sys but autoexec.nt and config.nt.
Last edited by aGerman on 24 Apr 2018 04:03, edited 1 time in total.
Reason: unrelated link removed

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#7 Post by Jer » 24 Apr 2018 10:08

pjanov, I don't know if your reply was meant as a solution.
I tried adding DEVICE=C:\WINDOWS\SYSTEM32\ANSI.SYS
in the file config.nt and it did not resolve the issue on
my Windows 7 laptop for displaying colors from ansi sequence
codes, such as:

Code: Select all

@echo off
For /F %%a In ('echo prompt $E^| cmd') Do Set "ESC=%%a"
Set "reset=%ESC%[0m"
echo %ESC%[38;5;1;48;5;11m colors %reset%
The solution I used on the Win 7 laptop is third-party ansicon, although
my primary PC O/S is Windows 10.

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: ANSI.SYS on Windows 7 PC Ineffective - Recommentation?

#8 Post by Jer » 02 May 2018 21:28

My apology because I spoke too soon about ansicon, a third-party application
to use ansi sequence codes in a batch script on a Windows 7 PC.
When I tested it, I saw colors in the console window :oops: but there were
only 16 colors, not the 256 colors displayed on my Win 10 64bit PC.

The documentation readme.txt says ansicon supports 256 color palette,
but I don't know if "support" means you should be able to display any
of the 256 colors, or that the closest of the 16 colors is selected with
the entry of higher number color codes.

I will continue with my project, colorize a file from a borders & box tool, with the 256 colors,
on the Win 10 PC, and now 2.7 million colors thanks to the post from einstein1969 showing RGB notation.

It would be helpful to know if anyone has experience with using ansi sequences in batch scripts
under Windows 7 32bit O/S, and how they made it work, to display any of the 256 colors or more.

Post Reply