<p>[更新]对于最新的Windows 10,请阅读@brainslaugs83的有用贡献,就在下面对这个答案的评论中</p>
<p>而对于<code>Windows 10 Anniversary Update</code>之前的版本:</p>
<p>ANSI.SYS有一个限制,即它只能在Windows 95 Vista下MS-DOS子系统的上下文中运行</p>
<p>Microsoft KB101875解释了如何在命令窗口中启用ANSI.SYS,<strong>但它不适用于Windows NT</strong>。根据文章:<a href="http://blog.mmediasys.com/2010/11/24/we-all-love-colors/" rel="noreferrer">we all love colors</a>,现代版本的Windows没有这种良好的ANSI支持</p>
<p>相反,Microsoft创建了许多函数,但这远远不是操作ANSI/VT100转义序列的需要</p>
<p>有关更详细的说明,请参见<a href="http://en.wikipedia.org/wiki/ANSI_escape_code" rel="noreferrer">Wikipedia article</a>:</p>
<blockquote>
<p>ANSI.SYS also works in NT-derived systems for 16-bit legacy programs executing under the NTVDM.</p>
<p>The Win32 console does not natively support ANSI escape sequences at all. Software such as <a href="https://github.com/adoxa/ansicon" rel="noreferrer">Ansicon</a> can however act as a wrapper around the standard Win32 console and add support for ANSI escape sequences.</p>
</blockquote>
<p>因此,我认为Jason Hood的ANSICON是您的解决方案。它是用<a href="http://en.wikipedia.org/wiki/C_Language" rel="noreferrer">C</a>编写的,支持32位和64位版本的Windows以及<a href="https://github.com/adoxa/ansicon" rel="noreferrer">the source is available</a></p>
<p>此外,我还发现了一些其他类似的问题或帖子,这些问题或帖子最终都得到了ANSICON的回答:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/946546/how-to-load-ansi-escape-codes-or-get-coloured-file-listing-in-winxp-cmd-shell">How to load ANSI escape codes or get coloured file listing in WinXP cmd shell?</a></li>
<li><a href="http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/how-to-use-ansisys-in-windows-7/86d06a2a-33d9-45d9-88c4-a7917b46392d" rel="noreferrer">how to use ansi.sys in windows 7</a></li>
<li><a href="http://answers.yahoo.com/question/index?qid=20070402210230AA8VFEy" rel="noreferrer">How can I get cmd.exe to display ANSI color escape sequences?</a></li>
<li><a href="http://jasonkarns.com/blog/ansi-color-in-windows-shells/" rel="noreferrer">ansi color in windows shells</a></li>
<li><a href="http://www.liferay.com/it/web/igor.spasic/blog/-/blogs/enable-ansi-colors-in-windows-command-prompt" rel="noreferrer">enable ansi colors in windows command prompt</a></li>
</ul>