Graphic CLI changed after run the powershell command in batch file

Solution 1:

I presume the problem stems from chcp 65001 being in effect, i.e. the UTF-8 code page.

With code page 65001 in effect, powershell.exe - the CLI of Windows PowerShell - indeed unfortunately exhibits the symptom you describe: the currently selected font is changed to a legacy raster font with limited glyph (character) support.

The following command demonstrates the problem (run from cmd.exe):

:: Unexpectedly switches to a raster font.
:: Note: No longer occurs in PowerShell (Core) 7+, with pwsh.exe
chcp 65001 & powershell -noprofile -c "'hi'"

You have the following options:

  • Run your batch file in Windows Terminal, available in the Microsoft Store instead of in a legacy console window.

  • You can temporarily switch to a code page other than 65001, assuming it still supports all the characters you need; applied to the example above:

    chcp 437 & powershell -noprofile -c "'hi'" & chcp 65001
    
  • You can switch from Windows PowerShell to PowerShell (Core) 7+, the install-on-demand, cross-platform successor edition. Its CLI, pwsh.exe, no longer exhibits the problem.