Running BAT/CMD file with accented characters in it

后端 未结 7 927
面向向阳花
面向向阳花 2021-01-31 05:51

I have a Windows batch file which has an instruction to execute an EXE file in a location whose path contains accented characters. Following are the contents of the batch file.<

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 06:12

    I had the same problem, and this answer solved it. Basically you have to wrap your script with a bunch of commands to change your terminal codepage, and then to restore it.

    @echo off
    for /f "tokens=2 delims=:." %%x in ('chcp') do set cp=%%x
    chcp 1252>nul
    
    :: your stuff here ::
    
    chcp %cp%>nul
    

    Worked like a charm!

提交回复
热议问题