Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

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

The error:

enter image description here

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
You are right. I actually wrote it in notepad++ in UTF-8. –  IMB Jan 11 '12 at 18:00
add comment

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?

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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