Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing codepage in .bat file (Win7 vs Win Vista)

I have a strange issue while trying to change the codepage in a .bat file.

When I execute the following .bat file in Windows 7 it executes fine.

The codepage gets changed and program.exe get executed.

The batch file:

chcp 65001

"D:\program.exe" /opt ÄiÜ

pause

However when I start the .bat file from Windows Vista the codepage gets changed and after that the batch file is exited.

So program.exe never gets executed.
However when I run the two commands manually from the commandline it does work.

Any idea how to get this working under Windows Vista from .bat file?

like image 762
PeeHaa Avatar asked Nov 14 '22 16:11

PeeHaa


1 Answers

It's new to me that this works with Win7, in Vista and XP it's normal that batch files aren't work if the codepage is changed to 65001.

But you can use a workaraound

(
  chcp 65001
  cmd /c type myFile.txt
  chcp 850
)
echo the batch is still alive

This works, as the complete block is cached while the codepage is changed.

In your case (with german umlauts) you could better use the codepage 1252

chcp 1252
echo ÄÖÜß
like image 171
jeb Avatar answered Jan 31 '23 03:01

jeb