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.

When executing certain files (mainly batch) using PsExec I get these weird ́╗┐' symbols before my command. My initial thought was, that I were using wrong encoding, but after checking, I realized that all my files were using UTF-8.

Would compiling the batch files into an exe solve the issue?

share|improve this question
    
Why not convert them to UTF-16LE instead? –  Ignacio Vazquez-Abrams May 29 '13 at 14:54
    
What's the difference? –  Locercus May 29 '13 at 14:56
    
The difference is that Windows doesn't usually use UTF-8. –  Ignacio Vazquez-Abrams May 29 '13 at 15:41
add comment

2 Answers

up vote 6 down vote accepted

I get these weird ́╗┐' symbols before my command […] all my files were using UTF-8.

This has two causes:

  1. cmd.exe does not support UTF-8. It always uses one of the single-byte encodings often called "OEM" – cp437, cp775, and so on, depending on the system's regional settings.

    (I expected it to support UTF-16 as well, but apparently not; not even if I added the UTF-16 BOM.)

  2. Your text editor is adding an UTF-8 "byte order mark" (bytes EF BB BF) to the beginning of all UTF-8 files.

    When cmd.exe reads your script, it doesn't know what to do with the mark – it sees the BOM as three ordinary cp437 characters, , and attempts to use them as part of the command name.

Configure your editor to stop adding the BOM to UTF-8–encoded files. (It only makes sense in UTF-16, and is very useless in UTF-8.)

Would compiling the batch files into an exe solve the issue?

uh

what

share|improve this answer
2  
I wouldn't say BOMs are "very useless" in UTF-8; though they are in this particular case. Many applications use them to determine the text actually is UTF-8 and not another encoding. –  Dour High Arch May 29 '13 at 15:09
add comment

Those are Unicode Byte Order Marks. Cmd.exe doesn't understand them. If you resave your files in Notepad with ANSI encoding, that should fix the problem.

For example, I created this batch file:

echo Hello World

First I save it with UTF-8 encoding

C:\Users\DSolimano\Desktop\junk>test.bat

C:\Users\DSolimano\Desktop\junk>echo Hello World
'echo' is not recognized as an internal or external command,
operable program or batch file.

Then with Unicode

C:\Users\DSolimano\Desktop\junk>test.bat

C:\Users\DSolimano\Desktop\junk>■e
'■e' is not recognized as an internal or external command,
operable program or batch file.

And finally with ANSI

C:\Users\DSolimano\Desktop\junk>test.bat

C:\Users\DSolimano\Desktop\junk>echo Hello World
Hello World
share|improve this answer
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.