Running BAT/CMD file with accented characters in it

Kryptic Coder picture Kryptic Coder · Sep 28, 2011 · Viewed 43k times · Source

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.

@echo off
C:\español\jre\bin\java.exe -version

C:\español\jre\bin\java.exe - This path exists and is proper. I can run this command directly on cmd.exe. But when I run the command from a bat/cmd file it fails saying "The system cannot find the path specified"

One way to fix this is by setting code page to 1252 (that works for me). But I'm afraid we'd have to set code pages for any non-English locale and figuring out which code page to use is pretty difficult.

Is there an alternative approach to fix this problem? Maybe a command-line option or something else?

Answer

katalin_2003 picture katalin_2003 · Mar 12, 2014

Another way of doing this, in Windows, is by using wordpad.exe:

  1. Run wordpad.exe
  2. Write your script as you usually do, with accents
  3. Choose Save as > Other formats
  4. Choose to save it as Text document MS-DOS (*.txt)
  5. Change the file extension from .txt to .bat