Running BAT/CMD file with accented characters in it

后端 未结 7 904
面向向阳花
面向向阳花 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:16

    Since you have @echo off you can't see what your batch is sending to the command prompt. Reproducing your problem with that off it seems like the ñ character gets misinterpreted since the output I see is:

    C:\espa±ol\jre\bin\java -version
    The system cannot find the path specified.
    

    I was able to get it to work by echoing the command into the batch file from the command prompt, i.e.

    echo C:\español\jre\bin\java.exe -version>>test.bat
    

    This seems to translate the character into whatever the command prompt is looking for, though I've only tested it with English locale set so I don't know if it'll work in all situations for you. Also, if you open the batch in a text editor like notepad it looks wrong (C:\espa¤ol\jre\bin\java.exe)

提交回复
热议问题