Reputation: 72672
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?
Upvotes: 5
Views: 8795
Reputation: 1
A less ugly solution, I use it when I need to use filenames with special characters as parameters in batch files:
If you type out the batchfile content in "dos" window ( type batchfilename.bat ) you will see the filename is correct. (It will also look correct in totalcommander built in fileviewer, but it will look garbage in notepad)
Upvotes: 0
Reputation: 72672
I've found a (very dirty) solution which works for me.
By the looks of it it just isn't possible what I want to do.
What I've done to make it work is the following:
As I said it's pretty dirty but it works for me.
If other answer are added here I'll try those as well.
Upvotes: 0
Reputation: 1885
Have you checked return code of chcp
(chcp 65001 & echo %ERRORLEVEL%
)?
Anyway, try chcp 65001 & "D:\program.exe" /opt ÄiÜ & chcp 850
.
Upvotes: 1
Reputation: 82327
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 ÄÖÜß
Upvotes: 1