I have the following .bat file which used to work without any error but for some reason it's started to return an error every time I run it.

Here's the .bat file:

start "" "C:\Program Files (x86)\NetBeans 7.0.1\bin\netbeans.exe"
start "" "D:\standalone\My AutoHotkey Script.ahk"

The error:

enter image description here


You wrote your command script in UTF-8. Those three characters are the UTF-8 encoding of the Unicode Byte Order Mark, U+FEFF, displayed in code page 437. Scripts for Microsoft's command processor are always treated by the command processor as if encoded the current "OEM" code page (clearly 437 in your case), and should be written as such.

The reason that everything looked alright in Notepad is that Notepad recognizes BOMs and decodes the file accordingly. What Notepad was showing you was not what the command processor actually sees in the file.

Note that Notepad has no ability to read/write files in OEM code pages. If you are using characters in command scripts that are outwith the ASCII subset common to "OEM" and "Windows" code pages (fortunately, not the case here), then you cannot use Notepad for editing those scripts (unless you are capable of translating from "OEM" to "Windows" code pages in your head as you type).

Even then, you'll have trouble when Notepad silently prepends byte-order marks to your files when you accidentally save as UTF-8 instead of in the current Windows code page (which Notepad mis-names "ANSI"). That's almost certainly what happened here, in fact.

  • You are right. I actually wrote it in notepad++ in UTF-8. – IMB Jan 11 '12 at 18:00

It seems the beginning of your BAT file has some character which can not be recognized by cmd (see first line of your screenshot).

Open your BAT file using Notepad, delete any strange characters, and save it; then run it again. Maybe the problem is solved?

  • There's no strange characters in the file. So I copy-pasted everything in a new file but same problem. Now I manually typed everything, seems to work. – IMB Jan 11 '12 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.