Use Scandinavian Characters in a Command-line script (BAT)

Purpose: You are in a need to use special characters (ie. Scandinavian Characters) in a Batch script.

You might notice that the default settings of Windows 7 CMD.exe does not allow you to call a script with Special Characters (ie. Scandinavian Characters). This occurs only when you call a Batch script from the CMD.exe. Typing directly in an open CMD session allows you to work with special characters. You can easily bypass the special character problem on your own workstation but might not be that straightforward to deploy the changes into your domain.

Alternative method: Use POWERSHELL instead of CMD to bypass your Special Character problems.

How to enable Scandinavian Character support
1) The first line of the Batch script must be left blank
2) Type the following in your script: chcp 65001
3) You can now call scripts with Scandinavian Characters

However, CMD.exe cannot call scripts with special characters, unless the font type of CMD.exe is set as a TrueType (TT) font. The font cannot be rasterfonts. Your cmd.exe will crash if you have incorrect font and type chcp 65001 into cmd.exe.

How to change cmd.exe default font from command line
1) Add a registry key to the following location as REG_SZ (String) with key name the next 
increasing amount of zeros (if there is a 0, then you must create a key with 00. If there is 0 and 00, 
you must create a key with 000, and so on). 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont

2) Put the value of the key to be the Font name that you want to use. 
You can find out your system font names from here:

3) A reboot of the workstation is essential for the CMD.exe to actually change the font it is using.

Microsoft has an article about this subject in TechNet.

Leave a Reply

Your email address will not be published. Required fields are marked *

three − = one

Post Navigation