cmd.exe启动时使用什么编码/代码页? [英] What encoding/code page is cmd.exe using when it is started?

查看:378
本文介绍了cmd.exe启动时使用什么编码/代码页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前问过一个几乎完全相同的问题。在答复中给出了对代码页的一个很好的解释,但它没有回答我在脑海里的问题:什么控制cmd.exe启动时使用的代码页?在我的系统上,它以某种方式改变。在注册表项HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet\Control\Nls\CodePage中,有一个项目OEMCP设置为437.这似乎是由cmd.exe使用的cmd.exe(如chcp所示)之后一个新的重新启动,但某些东西更改它,它在新的cmd.exe窗口中变为1252。如果我改变它与chcp到437,那只影响当前cmd.exe。当我退出并重新启动cmd.exe时,chcp在新窗口中显示1252。什么控制cmd.exe启动时使用的默认CP?它如何从注册表中的值更改?

解决方案

默认代码页在我的Windows系统上的 cmd.exe 是437,这是在美国(US)和西欧销售的大多数PC硬件的默认OEM代码页从我的' ve读。您可以通过在一个或两个键下添加一个名为 AutoRun 的字符串条目来更改此默认值:

  HKEY_CURRENT_USER \Software \Microsoft\Command处理器

  ;  和

  HKEY_LOCAL_MACHINE\软件\Microsoft \Command处理器



< %28WS.10%29.aspxrel =nofollow>此 MS Windows Server 2003支持页面。它描述了如何在一个或两个键下添加一个名为 AutoRun REG_SZ 字符串条目您希望在 cmd.exe 启动时自动运行。



例如,要使代码页1252为默认值,请在导航到一个之后创建一个名为 AutoRun 的新字符串值这些键在 regedit.exe 实用程序中,然后将其值设置为命令 chcp 1252 p>

虽然MS文章只表示它适用于Windows Server 2003,该技术也在我测试的Win XP系统上工作,因此也可能与Vista& Win 7。


A nearly identical question was asked before. A good explanation of code pages was given in the reply, but it did not answer the question in my mind: What controls the code page used when cmd.exe is started? On my system, it gets changed somehow. In the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage, there is an item OEMCP that is set to 437. This seems to be the CP used by cmd.exe (as shown by chcp) after a fresh reboot, but something changes it later and it becomes 1252 in new cmd.exe windows. If I change it with chcp to 437, that only affects the current cmd.exe. When I exit and restart cmd.exe, chcp shows 1252 in the new window. What controls the default CP used when cmd.exe is started? How does it get changed from the value in the registry? How do I keep it from getting changed and/or change it back to 437 for new command windows?

解决方案

The default code page in cmd.exe on my Windows syxtem is 437, which is the default OEM code page for most PC hardware sold in the United States (US) and Western Europe from what I've read. You can change this default by adding a string entry named AutoRun under one or both of the keys:

HKEY_CURRENT_USER\Software\Microsoft\Command Processor

    and

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor

in the Windows registry, as documented on this MS Windows Server 2003 support page. It describes how you can add a REG_SZstring entry named AutoRun under one or both of these keys with a value containing commands you want run automatically when cmd.exe starts up.

For example, to make code page 1252 the default, create a new string value named AutoRun after navigating to one of these keys in the regedit.exe utility program and then set its value to the command chcp 1252 afterwards.

Although the MS article only indicates it applies to Windows Server 2003, the technique also worked on the Win XP system I tested it on, so will probably also work with Vista & Win 7.

这篇关于cmd.exe启动时使用什么编码/代码页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆