‘…’ is not recognized as an internal or external command…
Is an error I got in Visual Studio 2008, when simply making a new .bat file to install a feature (code module for SharePoint) using script. The text cant be input here in WordPress so I have attached a picture above from my output window.
I often add a postbuild event for my SharePoint projects to easier install my features etc. to speed up development. I use the following:
CD $(ProjectDir)
Install.bat
I have done this a lot of time, but not in VS 2008
I had problems finding out what on earth was going on. It seemed like no matter what I wrote in the batch file it would simply not work.
I found out by scouring the Net, that the problem was encoding of the file. The standard encoding format for new text files in VS 2008 is UTF-8 and that is not the correct encoding for a batchfile. It needs to be saved in ASCII (ANSI in Notepad) format.
I will explain how to change the encoding in Visual Studio and Notepad.
Visual Studio 2008:
1: Open the “File” menu and choose “Save … As”
2: Click the little down arrow and choose “Save with Encoding”
This is what it looks like when you create a standard text file in VS2008:
3: Choose US-ASCII to save in correct encoding
My output on this simple feature is now:
You can also just change the encoding in Notepad which is a bit easier:
1: Simply open the file with Notepad and choose “Save As” and choose ANSI from the dropdownlist
Hope this helps someone.
Recommended reading
These book will help you tremendiously as a developer using Visual Studio 2008, if you are a .NET or a SharePoint programmer or not. Stop doing everything the hard way, and learn the ins and out of Visual Studio 2008.
Related posts:







Solid. This was driving me crazy in VS2008. Copying existing .bat files just wasn’t going to cut it. Thanks for the post!
Man, it saved my life!!! I was having problems with SQLCMD in a .bat using scripts divided in .sql files. Then I changed the .sql files encoding.
Thanks!!!