Friday, August 1, 2014

Batch Files in Visual Studio

A quick tip for anyone adding a new batch file to their Visual Studio projects: VS likes to add new text files in Unicode, which includes a byte order mark. The Windows Command Prompt interprets the byte order mark as characters, though, and so it fails to execute the first line.

To fix this, open up the offending batch file, and click the 'File->Save [Filename] as...' menu option. On the ensuing dialog, click the down-arrow next to the 'Save' button in the lower right and click 'Save with Encoding'. Choose to overwrite the existing file. Select the US-ASCII encoding and Windows (CR LF) line endings, and hit OK.

Your batch file should now execute without any issues, aside from the bugs you have written in it.

No comments:

Post a Comment