开发者

How do I resolve '@echo' is not a recognized command

I've implemented Scott Hanselman's method for keeping up with a dev/qa/prod version of web.config: http://www.hanselman.com/blog/CommentView.aspx?guid=93bfa4b3-44cd-4681-b70e-f4a2b0386466

For some reason when I compile my project I get this error message in my output window.

Any ideas?

------ Build started: Project: ABC.Flims.Web, Configuration: Development Any CPU ------
"C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\scripts/copyifnewer.bat" "C:\Projects\ballyhoo-tru开发者_运维技巧nk\src\ABC.Flims.Web\web.config.Development" "C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\web.config"
'@echo' is not recognized as an internal or external command,
operable program or batch file.  

Here is the script file:

@echo off
echo Comparing two files: %1 with %2

if not exist %1 goto File1NotFound
if not exist %2 goto File2NotFound

fc %1 %2 
if %ERRORLEVEL%==0 GOTO NoCopy

echo Files are not the same.  Copying %1 over %2
copy %1 %2 /y & goto END

:NoCopy
echo Files are the same.  Did nothing
goto END

:File1NotFound
echo %1 not found.
goto END

:File2NotFound
copy %1 %2 /y
goto END

:END
echo Done.


The file is probably Unicode encoded and has a Byte Order Mark (BOM) at the start that is throwing off the batch processor.

Save it as an ASCII file and you should be OK. You can do this in notepad - select Save As... from the File menu and ensure that the Encoding dropdown is set to ANSI.


Stumbled upon a similar issue. Found that within visual studio, if you open your *.bat file, you can choose File -> Advanced Save Options. From the drop-down menu under encoding, select 'US-ASCII - Codepage 20127'


A file named echo.

P:\>echo.


P:\>dir /b echo
File Not Found

P:\>echo echo >echo

P:\>dir /b echo
echo

P:\>echo.
'echo.' is not recognized as an internal or external command,
operable program or batch file.

P:\>del echo

P:\>dir /b echo
File Not Found

P:\>echo.


P:\>

An echo in current folder or in the path will cause this.

/echo


I think your file is Unicode encoded and needs to be ascii.


My two cents: check for a file "echo." in the same folder as the batch script. When there, delete it.

C:\Scripts>echo.

'echo.' is not recognized as an internal or external command,
operable program or batch file.

C:\Scripts>dir echo*.*

 Volume in drive C has no label.
 Volume Serial Number is 46CF-DC0A

 Directory of C:\Scripts

11/04/2022  06:50 AM                 0 echo
               1 File(s)              0 bytes
               0 Dir(s)  686,672,957,440 bytes free

C:\Scripts>del echo.

C:\Scripts>dir echo*.*

 Volume in drive C has no label.
 Volume Serial Number is 46CF-DC0A

 Directory of C:\Scripts

File Not Found

C:\Scripts>echo.


C:\Scripts>


C:\Windows\echo ==> some times there is a file which is called "echo" without extension. and it caused this error : 'echo.' is not recognized as an internal or external command,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜