Invalid character in .bat file

1

Gentlemen!

I have a .bat file that I use to start Apache Tomcat from my application in debug mode. However when running this file in CMD, the first thing displayed is the following message:

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

I emphasize that after this, the script works normally, but I wonder if anyone has ever had something similar or knows a solution. I had tried to redo it, but the error persists.

The following is the content of the file:

@echo off

echo.

rd /s /q C:\sas\Instances\sa7\tomcat\work\
rd /s /q C:\sas\Instances\sa7\tomcat\conf\Catalina\
del /s /q C:\sas\Instances\sa7\tomcat\logs\*
del /s /q C:\sas\Instances\sa7\tomcat\temp\*
del /s /q C:\sas\Instances\sa7\tomcat\webapps\sa\WEB-INF\web.xml.template
del /s /q C:\sas\Instances\sa7\tomcat\webapps\sa\META-INF\context.xml.template

echo.

xcopy /s /q /y C:\sas\instances\sa7\runtime\* C:\sas\instances\sa7\tomcat\webapps\sa\

echo.

set CATALINA_HOME=C:\sas\instances\Sa7\tomcat
set CATALINA_BASE=C:\sas\instances\Sa7\tomcat
set JAVA_HOME=C:\sas\java\jdk7
set INSTANCE=C:\sas\instances\Sa7

set CATALINA_OPTS=-Xms256m -Xmx512m -XX:MaxPermSize=256m 

set CATALINA_OPTS=%CATALINA_OPTS% -Dfile.encoding=UTF-8
set CATALINA_OPTS=%CATALINA_OPTS% -Djava.awt.headless=false
set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote
set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.port=9014
set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
set CATALINA_OPTS=%CATALINA_OPTS% -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false
set CATALINA_OPTS=%CATALINA_OPTS% -Duser.timezone=America/Sao_Paulo
set CATALINA_OPTS=%CATALINA_OPTS% -Duser.language=pt
set CATALINA_OPTS=%CATALINA_OPTS% -Duser.region=BR
set CATALINA_OPTS=%CATALINA_OPTS% -Dsun.java2d.noddraw=true
set CATALINA_OPTS=%CATALINA_OPTS% -Dsun.java2d.d3d=false
set CATALINA_OPTS=%CATALINA_OPTS% -Xdebug 
set CATALINA_OPTS=%CATALINA_OPTS% -Xrunjdwp:transport=dt_socket,address=8990,server=y,suspend=n

%CATALINA_HOME%\bin\startup.bat
    
asked by anonymous 23.11.2016 / 16:45

2 answers

3

Your file was possibly saved with UTF-8 COM BOM (BOM being the abbreviation of BYTE ORDER MARK) in Notepad, ie at the top of the document .bat or any When you save a byte-order mark character with UTF-8 BOM , you have already been quoted in some questions here on the site, more details about the BOM in utf-8 and others as utf-32 in:

Basically your .bat thinks that this character called byte-order mark is a command, in which case the unicode character U+FEFF is printed as ´╗┐ , then .bat looks for a program with that name, which probably does not exist, thus causing an unrecognized command or program error.

I created an example saving in UTF-8 via Windows Notepad:

@echo off

echo Oi

pause

In case I left a line before @echo off and then when the execution occurred the same error occurred:

Seethatitisthesamecharacter´╗┐

IfyouwanttouseUTF-8youshouldsavewithUTF-8withoutBOMoruseANSI(oranycompatibleformat),itwilldependontheneed.

IfyoustillwanttouseUTF-8youshouldmakeuseofamoreadvancedprogram,suchasnotepad++thatcanbedownloadedat:

  • link

Open your .bat on it and save it like this:

  

Ifutf-8isnotrequiredforyouinthenotepaditselfselectSaveAs...andselectANSI:

  

    
18.12.2018 / 19:15
0

Luís Felipe Dal Molin, good afternoon

Possibly your problem is not in the batch, but in the character page used in the system in the by the interface of the / cli prompt, I suggest to check the settings of the keys:

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Nls \ CodePage \ OEMCP Verify that something other than "850" or "1252" is displayed

Another value is just changing 850, or 1252

I have had problems when I needed to display a character that appeared in chp 65001, after I change the value in the key, returning to the default chcp 850, my batchs stopped displaying that same message with these characters ..

have post that helped me: this was 1 this was another

    
18.11.2018 / 20:18