我在脚本中用到了中文,并添加了chcp 65001命令,文件保存为UTF 8,cmd字体是默认的新宋体,在大部分情况下都能正常运行,结果遇到了下面这种特殊的情况出现了报错 | @echo off | | chcp 65001 > nul | | set "i=1" | | | | :wait_loop | | echo %i% | | set /a "i+=1" | | if %i% lss 4 ( | | goto :wait_loop | | ) | | pauseCOPY |
报错内容: | 1 | | '�动' is not recognized as an internal or external command, | | operable program or batch file. | | 2 | | '�动' is not recognized as an internal or external command, | | operable program or batch file. | | 3 | | Press any key to continue . . .COPY |
我尝试了发现将“rem 轮询,等待服务启动”改成“rem 撒旦撒服务启动”或其他可以正常;或者将“chcp 65001 > nul ”去掉,然后保存成GBK编码可以正常;再或者在“rem 轮询,等待服务启动”下方插入一行空白行也能正常运行。
在我看来这种非常诡异,请问是隐藏的bug还是有我还没了解清除的规则?求解答,谢谢。 |